MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / paren_follows_cursor

Function paren_follows_cursor

src/completion/handler.rs:83–91  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

81/// present and inserting a snippet with its own `()` would produce
82/// double parentheses like `method()()`.
83fn 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///

Calls 1

position_to_byte_offsetFunction · 0.85

Tested by

no test coverage detected