Check whether a `(` immediately follows the cursor position (past any partial identifier the user has already typed). When the user is renaming an existing call — `$obj->oldName|()`, `functionNa|()`, `new ClassNa|()` — the opening paren is already present and inserting a snippet with its own `()` would produce double parentheses like `method()()`.
(content: &str, position: Position)
| 81 | /// present and inserting a snippet with its own `()` would produce |
| 82 | /// double parentheses like `method()()`. |
| 83 | fn paren_follows_cursor(content: &str, position: Position) -> bool { |
| 84 | let byte_off = position_to_byte_offset(content, position); |
| 85 | let rest = &content[byte_off..]; |
| 86 | // Skip past any partial identifier the user has typed |
| 87 | // (ASCII letters, digits, underscore, backslash for namespaced names). |
| 88 | let after_ident = |
| 89 | rest.trim_start_matches(|c: char| c.is_ascii_alphanumeric() || c == '_' || c == '\\'); |
| 90 | after_ident.starts_with('(') |
| 91 | } |
| 92 | |
| 93 | /// Downgrade callable snippet items to plain-name insertions. |
| 94 | /// |
no test coverage detected