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

Autosave + trim trailing whitespace can change indentation for tabstops in snippets #45146

Closed
JakeBecker opened this issue Mar 6, 2018 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@JakeBecker
Copy link

Issue Type

Bug

Description

With settings:

  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 1000,
  "files.trimTrailingWhitespace": true,

When using a snippet that has a tabstop following some whitespace, if you take long enough for autosave to kick in, it can remove the whitespace before the tab stop and affect its indentation. For example, in the snippet for an Elixir function definition:

def $1 do
  $0
end

If you wait for a second while focused on the $1 tabstop, it will autosave and remove the whitespace before the $0. When you tab to it, the cursor will be all the way at the leftmost column.

PS. VS Code is fantastic and I am sorry to add another issue to your already huge pile.

VS Code Info

VS Code version: Code 1.20.1 (f88bbf9, 2018-02-13T15:23:28.607Z)
OS version: Darwin x64 16.7.0

System Info
Item Value
CPUs Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz (8 x 2500)
Load (avg) 2, 2, 2
Memory (System) 16.00GB (4.12GB free)
Process Argv /Applications/Visual Studio Code.app/Contents/MacOS/Electron
Screen Reader no
VM 0%
(I did not check whether reproducible without extensions because it does not seem like an extension issue)
@vscodebot vscodebot bot added editor editor-core Editor basic functionality labels Mar 6, 2018
@jrieken jrieken assigned bpasero and unassigned jrieken Mar 8, 2018
@bpasero bpasero assigned alexdima and unassigned bpasero Mar 8, 2018
@bpasero
Copy link
Member

bpasero commented Mar 8, 2018

Ping pong, but that command is not from me. I also think it needs some support from the editor to find out that a region is currently in snippet mode.

@JakeBecker
Copy link
Author

Interestingly, I still seem to get this issue when I set files.trimTrailingWhitespace to false.

@alexdima
Copy link
Member

The editor does not "know" that there is a snippet controller that adds markers and uses them as tab stops, as snippets are not a core editor concept. However, we could make some of the saving code ask SnippetController2 if it is active...

@alexdima alexdima added bug Issue identified by VS Code Team member as probable bug and removed editor-core Editor basic functionality labels Apr 19, 2018
@alexdima
Copy link
Member

For verification, use:

    "files.autoSave": "afterDelay",
    "files.trimTrailingWhitespace": true

And insert a snippet like the for loop in JS.

@alexdima alexdima added this to the April 2018 milestone Apr 19, 2018
@RMacfarlane RMacfarlane added the verified Verification succeeded label Apr 26, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 3, 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 verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

5 participants