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

showInlineCompletions and TabCompletions don't work well together #125328

Closed
TylerLeonhardt opened this issue Jun 2, 2021 · 7 comments
Closed
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug inline-completions insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@TylerLeonhardt
Copy link
Member

Testing #124979

Apply these settings:

"editor.suggest.showInlineCompletions": true,
"editor.tabCompletion": "on"

with this code:

import * as vscode from 'vscode';

export class LoremInlineCompletionItemProvider implements vscode.InlineCompletionItemProvider {
    public static documentSelector: vscode.DocumentSelector = {
        pattern: "**"
    };

    private static allSuggestions = [
		'arguments ipsum ',
		`arguments foo`,
		`arguments bar`,
	];

    provideInlineCompletionItems(document: vscode.TextDocument, position: vscode.Position, context: vscode.InlineCompletionContext, token: vscode.CancellationToken): vscode.ProviderResult<vscode.InlineCompletionList<vscode.InlineCompletionItem> | vscode.InlineCompletionItem[]> {
        const text = document.getText(document.getWordRangeAtPosition(position));
        if (!text || !text.startsWith('a')) {
            return [];
        }

        return LoremInlineCompletionItemProvider.allSuggestions.map(s => { return <vscode.InlineCompletionItem>{ text: s }});
    }
}

Here's what I see. There's no way to accept an inline completion:
no-way-to-accept

@hediet hediet added the bug Issue identified by VS Code Team member as probable bug label Jun 3, 2021
@hediet hediet added this to the June 2021 milestone Jun 3, 2021
@hediet
Copy link
Member

hediet commented Jun 3, 2021

Thanks for reporting this! Yes, this scenario is currently not supported.

@hediet
Copy link
Member

hediet commented Jun 17, 2021

It seems like a simple weight adjustment did the trick. I thought there was some complicated interaction causing problems.

@TylerLeonhardt
Copy link
Member Author

Doesn't this flip the problem though @hedie? Now tab completion won't work with inline completion?

@hediet
Copy link
Member

hediet commented Jun 17, 2021

Tab completion will not work if an inline completion is visible, that is right. However, if no inline completion is visible, tab completion will work.

I think it is fair to give the inline completion precedence, since it is visible and can be canceled with escape (and then tab completion would have precedence). What are your thoughts?

@TylerLeonhardt
Copy link
Member Author

I think that's fine so long as 2 things happen:

  • ghost text should take a second or 2 to show up (so that I can hit tab tab tab and only get tab completion until I'm on the suggestion that I want ghost text to show up on
  • if I ESC ghost text, hitting Tab should trigger tab completion I think.

Alternatively, and maybe harder, have the suggest widget pop up in tab completion...because it's my understanding that the suggest widget and ghost text can't be displayed at the same time?

@hediet
Copy link
Member

hediet commented Jun 18, 2021

Alternatively, and maybe harder, have the suggest widget pop up in tab completion...

Don't you get this behavior when enabling quick suggest?

if I ESC ghost text, hitting Tab should trigger tab completion I think.

This should work already.

ghost text should take a second or 2 to show up (so that I can hit tab tab tab and only get tab completion until I'm on the suggestion that I want ghost text to show up on

Hmm, you could also disable inline suggestions and trigger them manually (there is a command for that). I'm not a huge fan of making the 1-2 seconds delay default (or even a default when tab completion is on). Though it could make sense to have a setting to set a delay value.

@TylerLeonhardt
Copy link
Member Author

Don't you get this behavior when enabling quick suggest?

I wasn't clear there, my bad. I meant that the suggest widget would stay open after you hit tab and then when you hit Tab again it would change the text in the editor and the suggest widget would move the cursor down to the second option, and then tab again would change the text in the editor and move the cursor down to the third option, etc.

I thought I saw other editors do this, but I can't seem to get it working that way again so maybe I dreamt it 😆

in any case, ignore that point.

@TylerLeonhardt TylerLeonhardt added the verified Verification succeeded label Jun 30, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug inline-completions insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants
@TylerLeonhardt @hediet and others