editor: Fix function completion expansion in string contexts and call expressions (#30351)

Closes #27582

Now, when accepting function completion, it doesn't expand with
parentheses and arguments in the following cases:
1. If it's in a string (like `type Foo = MyClass["sayHello"]` instead of
`type Foo = MyClass["sayHello(name)"]`)
2. If it's in a call expression (like `useRef<HTMLDivElement>(null)`
over `useRef(initialValue)<HTMLDivElement>(null)`)

This is a follow-up to https://github.com/zed-industries/zed/pull/30312,
more like cleaner version of it.

Release Notes:

- Fixed an issue where accepting a method as an object string in
JavaScript would incorrectly expand. E.g. `MyClass["sayHello(name)"]`
instead of `MyClass["sayHello"]`.
This commit is contained in:
Smit Barmase 2025-05-09 02:22:52 -07:00 committed by GitHub
parent 851ab13f94
commit b88ba44b32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 39 additions and 21 deletions

View file

@ -34,3 +34,7 @@ opt_into_language_servers = ["emmet-language-server"]
[overrides.string]
completion_query_characters = ["-", "."]
opt_into_language_servers = ["tailwindcss-language-server"]
prefer_label_for_snippet = true
[overrides.call_expression]
prefer_label_for_snippet = true

View file

@ -13,3 +13,5 @@
(jsx_self_closing_element)
(jsx_expression)
] @default
(_ value: (call_expression) @call_expression)

View file

@ -21,3 +21,7 @@ debuggers = ["JavaScript"]
[overrides.string]
completion_query_characters = ["."]
prefer_label_for_snippet = true
[overrides.call_expression]
prefer_label_for_snippet = true

View file

@ -1,2 +1,4 @@
(comment) @comment.inclusive
(string) @string
(_ value: (call_expression) @call_expression)