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

Tab does not work as a trigger character for #89826

Open
ericbiewener opened this issue Jan 31, 2020 · 8 comments
Open

Tab does not work as a trigger character for #89826

ericbiewener opened this issue Jan 31, 2020 · 8 comments
Assignees
Labels
suggest IntelliSense, Auto Complete under-discussion Issue is under discussion for relevance, priority, approach

Comments

@ericbiewener
Copy link

  • VSCode Version: 1.41.1
  • OS Version: Mac 10.14.6

Steps to Reproduce:

Register a CompletionProvider with tab (\t) as a trigger character:

vscode.languages.registerCompletionItemProvider(
  'yaml', myCompletionItemProvider, ' ', '\n', '\t'
)

In the above example, the space and new line characters successfully trigger my completion provider, but not tab. This is the case whether my text editor is using tabs or spaces.

@jrieken jrieken added info-needed Issue requires more information from poster suggest IntelliSense, Auto Complete labels Feb 3, 2020
@jrieken
Copy link
Member

jrieken commented Feb 3, 2020

Yeah, that kinda wanted because using space, newline, and tab is a bit of an anti-usage of trigger characters. What is you use-case for this? What language needs such trigger characters?

@ericbiewener
Copy link
Author

My use case is autocompletion for yaml. Since yaml is whitespace significant, the autocompletion needs to suggest different options depending on indentation levels.

@jrieken
Copy link
Member

jrieken commented Feb 4, 2020

Since yaml is whitespace significant, the autocompletion needs to suggest different options depending on indentation levels.

That I understand, but all the whitespace and indentation levels are inside the document that you receive when being triggered (in whatever way). Tho, I do wonder if yaml users expect that IntelliSense is triggered by whitespace... Our intent for them is to trigger exclusive completions in cases like member completion, e.g . being a trigger character. "General" completion is trigger by typing words (quick suggestion) and by explicitly requesting completions (ctrl+space)

@ericbiewener
Copy link
Author

I guess it's a question of whether VS Code should block tab as a trigger character because it isn't desirable in the vast majority of use cases, even if there may be some rare cases where it would be useful. I'd advocate for VS Code leaving that decision up to extension authors rather than simply preventing the option outright.

@jrieken
Copy link
Member

jrieken commented Feb 5, 2020

I guess it's a question of whether VS Code should block tab as a trigger character because it isn't desirable in the vast majority of use cases

It's not that we are blocking anything but tab doesn't reach us like other characters do. To implement trigger characters we have a "typing listener" which spies on what's being typed. Pressing tab, doesn't perform a type-operation but a more complex insert operation because pressing tab might mean "insert 4 spaces", "insert 2 spaces", "insert \t" etc. That's why we are bling on that eye.

Rephrasing my question, what is a good sample yaml-snippet in which tab should trigger completions (from only your provider)?

@ericbiewener
Copy link
Author

- someObject:
    |

In the above example, imagine I have just tabbed to the pipe character.

@jrieken jrieken added under-discussion Issue is under discussion for relevance, priority, approach and removed info-needed Issue requires more information from poster labels Apr 7, 2020
@Brianzchen
Copy link

@jrieken Does my use case with flowtype above ☝️ give reason to implement this change?

@rikinsk
Copy link

rikinsk commented Feb 13, 2024

Ran into the same issue. We're trying to trigger completions for yaml files when tab is hit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggest IntelliSense, Auto Complete under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

4 participants