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

Tweak undo behaviour when having commit characters #44155

Closed
jVanZwieten opened this issue Feb 21, 2018 · 8 comments
Closed

Tweak undo behaviour when having commit characters #44155

jVanZwieten opened this issue Feb 21, 2018 · 8 comments
Assignees
Labels
feature-request Request for new features or functionality suggest IntelliSense, Auto Complete verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@jVanZwieten
Copy link

Issue Type

Feature Request

Description

The suggestions and suggestion widget of VSCode Intellisense is inaccessible to extension API. In order to capture the suggestion for later use, I must do the following:

    async function getSuggestion(): Promise<string>  {
        await vscode.commands.executeCommand('acceptSelectedSuggestion')

        const suggestionRange = document.getWordRangeAtPosition(editor.selection.active)
        const suggestion = editor.document.getText(suggestionRange)

        await vscode.commands.executeCommand('undo')
        return suggestion
    }

Which is silly, it should just be like:
let suggestion = vscode.window.activeTextEditor.suggestionWidget.suggestion

Furthermore, I can't check the type of suggestion. In my case, I'd like to defend against snippets and bypass my logic in that case.

VS Code Info

VS Code version: Code - Insiders 1.21.0-insider (70e020b, 2018-02-15T05:17:01.988Z)
OS version: Windows_NT x64 10.0.16299

@jrieken jrieken added the info-needed Issue requires more information from poster label Feb 26, 2018
@jrieken
Copy link
Member

jrieken commented Feb 26, 2018

The suggestions and suggestion widget of VSCode Intellisense is inaccessible to extension API. In order to capture the suggestion for later use,

Yeah, that's the design of the API - define data contracts and interactions but don't mention the UI. This gives us freedom to redefine the UI without changing extensions and therefore it's unlikely this will happen any time soon.

I wonder what you are trying to achieve and 'later use' is for? There might another way to achieve what you want. For instance a completion command could be used for this...

@jVanZwieten
Copy link
Author

It's fair to abstract away the actual UI, but my suggestion is really not about the UI, it's about the auto-completion suggestions themselves. I want to identify the selectedSuggestion, for 2 reasons:

  1. Save the suggestion to a variable, for later use
  2. test if the suggestion is a snippet, method, property, etc, which of course I know VSCode knows because it has the different icons for each

In my case, I save the suggestion for later use in order to implement the accept and type character with an undo order like Visual Studio. That way the user can undo the accepted suggestion if they didn't want it, they actually wanted the key they typed (as in VS). You can see this at work in my extension. In order to get that 'proper' undo order, I have to type the accept character, and then insert the suggestion, by which time VSCode's suggestion widget is no longer open.

Thanks for your consideration!

@jrieken
Copy link
Member

jrieken commented Feb 27, 2018

to implement the accept and type character with an undo order like Visual Studio

Hm... Isn't that very similar to the built-in feature of accept-characters? Check the "editor.acceptSuggestionOnCommitCharacter": true-setting and the CompletionItem#commitCharacters. Is there anything missing from the feature?

@jVanZwieten
Copy link
Author

2 things missing from this feature:

  1. It doesn't work the first time. I have to use tab for the first commit. So for example, if I were looking to type:
    vscode.window.activeTextEditor.suggestionWidget.suggestion
    I'd have to use tab to complete vscode, and the rest of the properties could be completed using ..
  2. It gives the wrong undo order. Say I want to type vscode.win., this would autocomplete to vscode.window.. As in VS, I should be able to immediately undo to get vscode.win. but instead I would get vscode.window since the . is on top of the undo stack.

@jrieken
Copy link
Member

jrieken commented Feb 28, 2018

vscode.window.activeTextEditor.suggestionWidget.suggestion
I'd have to use tab to complete vscode, and the rest of the properties could be completed using ..

@mjbvz This seems to be a bug in TypeScript/JavaScript

As in VS, I should be able to immediately undo to get vscode.win. but instead I would get vscode.window since the . is on top

That's a good suggestion and something we can tweak

@jrieken jrieken added the suggest IntelliSense, Auto Complete label Feb 28, 2018
@vscodebot vscodebot bot closed this as completed Mar 7, 2018
@vscodebot
Copy link

vscodebot bot commented Mar 7, 2018

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!

@jVanZwieten
Copy link
Author

Hello,

Was there any information that was being waited on, or has this suggestion been rejected?

@jrieken jrieken removed the info-needed Issue requires more information from poster label Mar 8, 2018
@jrieken jrieken reopened this Mar 8, 2018
@jrieken
Copy link
Member

jrieken commented Mar 8, 2018

Yeah, over-eager bot

@jrieken jrieken changed the title expose suggestion widget in extension API Tweak undo behaviour when having commit characters Jul 27, 2018
@jrieken jrieken added the feature-request Request for new features or functionality label Jul 27, 2018
@jrieken jrieken added this to the October 2019 milestone Oct 8, 2019
@jrieken jrieken added the verification-needed Verification of issue is requested label Oct 28, 2019
@roblourens roblourens added the verified Verification succeeded label Oct 29, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality suggest IntelliSense, Auto Complete verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

4 participants