Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to vary completion item insertion (based on chosen commit character?) #70824

Open
Gama11 opened this issue Mar 20, 2019 · 1 comment
Open
Assignees
Labels
feature-request Request for new features or functionality suggest IntelliSense, Auto Complete
Milestone

Comments

@Gama11
Copy link
Contributor

Gama11 commented Mar 20, 2019

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?

@Gama11 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
@jrieken jrieken added feature-request Request for new features or functionality suggest IntelliSense, Auto Complete labels Mar 20, 2019
@Gama11
Copy link
Contributor Author

Gama11 commented Apr 9, 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality suggest IntelliSense, Auto Complete
Projects
None yet
Development

No branches or pull requests

2 participants