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

Auto-imports don't work when using trigger characters #42859

Closed
mjbvz opened this issue Feb 3, 2018 · 3 comments
Closed

Auto-imports don't work when using trigger characters #42859

mjbvz opened this issue Feb 3, 2018 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug javascript JavaScript support issues typescript Typescript support issues verified Verification succeeded
Milestone

Comments

@mjbvz
Copy link
Collaborator

mjbvz commented Feb 3, 2018

  • VSCode Version:
  • OS Version:

Steps to Reproduce:

  1. In a project:

a.js:

export function foo() {}

b.js:

fo
  1. Trigger suggestions on fo in b.js
  2. Select the auto import suggestion for foo.
  3. Press ( to accept completion

Bug
Auto import not added

@mjbvz mjbvz added bug Issue identified by VS Code Team member as probable bug typescript Typescript support issues javascript JavaScript support issues labels Feb 3, 2018
@mjbvz mjbvz added this to the February 2018 milestone Feb 3, 2018
@mjbvz mjbvz self-assigned this Feb 3, 2018
@mjbvz
Copy link
Collaborator Author

mjbvz commented Feb 7, 2018

Root cause seems to be that the workspaceedit we provide gets invalidated, possibly by the editor bracket completions

@mjbvz
Copy link
Collaborator Author

mjbvz commented Feb 7, 2018

@jrieken Just confirmed that this is indeed the root cause. Sequence of behavior is:

  1. User accept suggestion. This suggestion has a command registered on it
  2. The suggest controller processes the suggestion and invokes the command.
  3. Bracket matching kicks in for the original suggestion insertion
  4. The command form the suggestion is invoked in the TS extension. This command builds up a workspace edit.
  5. The workspace edit is applied within the command. However the editor model has changed since the workspace edit was created, so the operation fails

Possible workaround would be to change to use additionalTextEdits instead of a command in TS (however we sometimes would still need the command)

@jrieken
Copy link
Member

jrieken commented Feb 26, 2018

Note that
* additional modifications to the current document should be described with the
* additionalTextEdits-property.

Yeah, don't use a command to edit the text document... We should really work on migrating TypeScript away from such hacks

@mjbvz mjbvz modified the milestones: February 2018, March 2018 Feb 27, 2018
@jrieken jrieken removed their assignment Mar 13, 2018
@mjbvz mjbvz closed this as completed in e769928 Mar 20, 2018
@tsalinger tsalinger added the verified Verification succeeded label Mar 29, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators May 4, 2018
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 javascript JavaScript support issues typescript Typescript support issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants