You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CompletionItem allows setting a list of commit characters that can be used to select the item. However, what you can do with that in practice is limited, since the insertion will always be the same no matter which commit character was used.
It would be very powerful if the insertion could vary depending on which commit character was selected (insertText, additionalTextEdits).
Here's an example of one of the use cases we wanted to support in the Haxe extension:
When inserting an unimported type, we have two options: generate an import via additionalTextEdits, or insert the fully qualified path instead. You don't always want the same behavior here, so it would be neat if you could for instance:
use Enter to generate the import and insert the unqualified name
use Tab to insert the fully qualified name
Right now, there's two workarounds:
Duplicate each completion item, so you have one for auto-importing and one for inserting fully quallified names. However, this would make for a very messy completion list, so we don't do this in the Haxe extension.
Have a setting that controls which behavior should be used. We do have this in the Haxe extension, but as mentioned before, sometimes you want to decide which one to use "in the moment", without having to mess with settings.
There's precedent for this sort of behavior in other IDEs. For instance in IntelliJ (Java), you can use Alt+Enter to open a code action menu on completion items. There you can for instance choose to import a method statically:
Perhaps allowing "code actions" on completion items like that is better than basing it purely on which commit character was used, as it's much more explicit.
Thoughts?
The text was updated successfully, but these errors were encountered:
Gama11
changed the title
Ability to vary insertion based on chosen commit character
Ability to vary completion item insertion (based on chosen commit character?)
Mar 20, 2019
It just occurred to me that this would also immensely improve the UX for function calls:
TS / JS / Haxe allow ( as a commit character for inserting functions. This also auto-inserts the closing ) automatically due to auto closing braces, so you end up with:
func(|)
With the cursor positioned within the parens. However, if func accepts no arguments, what you would really want is:
func()|
It seems like currently this can't be supported, because if completion did include the entire () in these cases in its insertion while still allowing ( as a commit character, you would end up with func()(|). You would need to be able to "suppress" the the commit character somehow.
CompletionItem
allows setting a list of commit characters that can be used to select the item. However, what you can do with that in practice is limited, since the insertion will always be the same no matter which commit character was used.It would be very powerful if the insertion could vary depending on which commit character was selected (
insertText
,additionalTextEdits
).Here's an example of one of the use cases we wanted to support in the Haxe extension:
additionalTextEdits
, or insert the fully qualified path instead. You don't always want the same behavior here, so it would be neat if you could for instance:There's precedent for this sort of behavior in other IDEs. For instance in IntelliJ (Java), you can use Alt+Enter to open a code action menu on completion items. There you can for instance choose to import a method statically:
Perhaps allowing "code actions" on completion items like that is better than basing it purely on which commit character was used, as it's much more explicit.
Thoughts?
The text was updated successfully, but these errors were encountered: