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

Extra spaces being added to JS files on copy/paste #15118

Closed
smlombardi opened this issue Nov 7, 2016 · 3 comments
Closed

Extra spaces being added to JS files on copy/paste #15118

smlombardi opened this issue Nov 7, 2016 · 3 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-textbuffer Editor text buffer verified Verification succeeded
Milestone

Comments

@smlombardi
Copy link

smlombardi commented Nov 7, 2016

  • VSCode Version: Code - Insiders 1.8.0-insider (d3f1489, 2016-11-07T07:05:13.526Z)
  • OS Version: Darwin x64 16.1.0
  • Extensions:
Extension Author Version
code-settings-sync Shan 2.3.7
sort-lines Tyriar 1.1.0
html-css-class-completion Zignd 1.0.3
html-snippets abusaidm 0.0.18
Bookmarks alefragnani 0.10.0
project-manager alefragnani 0.12.2
one-monokai azemoh 0.1.15
path-intellisense christian-kohler 1.1.0
vscode-eslint dbaeumer 1.0.8
tslint eg2 0.5.40
auto-close-tag formulahendry 0.3.4
auto-rename-tag formulahendry 0.0.7
Angular1 johnpapa 0.1.16
theme-karyfoundation-themes karyfoundation 7.4.0
vscode-stylefmt mrmlnc 2.0.1
nonbreakingspace smlombardi 0.0.1
stylelint shinnn 0.18.1
theme-tesla smlombardi 0.0.1
autoimport steoates 1.2.2
bootstrap-3-snippets wcwhitehead 0.0.8
change-case wmaurer 1.0.0

Steps to Reproduce:

  1. put cursor in line to copy. The line has no trailing spaces.
  2. put cursor after line where you want to paste code. hit return to make a new line.
  3. paste. code wraps to next line, as expected
  4. hit "delete" key until cursor moves back up to the prior (pasted) line, after the semicolon. You can see the cursor right up against the semicolon.
  5. notice the semicolon has a red "error" squiggle. hovering says it's due to trailing spaces.
  6. Drag cursor to the right of the semicolon, there are indeed spaces!

Where the heck did those come from??

nov-07-2016 13-36-33

@alexdima
Copy link
Member

alexdima commented Nov 8, 2016

@smlombardi Those spaces get added when pressing enter and they are not "garbage-collected" when pasting, my guess because they are near to the range (touching) where the paste occurs. This becomes a lot more clear if you enable renderWhitespace:

paste-whitespace

We need to investigate why the auto-whitespace is not removed in this case, my guess is that the paste edit range touches the auto-whitespace, tricking it into thinking it was useful, when in fact it wasn't.

As a workaround, if you copy without a selection, pasting will always paste a new line above your cursor position. I use alt+up/down to adjust if it wasn't perfect.
paste-whitespace-no-enter

@alexdima alexdima added bug Issue identified by VS Code Team member as probable bug editor-core Editor basic functionality labels Nov 8, 2016
@alexdima alexdima added this to the Backlog milestone Nov 8, 2016
@smlombardi
Copy link
Author

Thanks for the tip. I don't recall this happening in older versions.

@alexdima
Copy link
Member

alexdima commented Nov 8, 2016

Maybe you had enabled trimTrailingWhitespace in the past and/or auto-save ... ? But this behaviour is in since ... forever :)

@alexdima alexdima added editor-textbuffer Editor text buffer and removed editor-core Editor basic functionality labels Apr 17, 2018
@alexdima alexdima modified the milestones: Backlog, May 2018 May 2, 2018
@sbatten sbatten added the verified Verification succeeded label May 30, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 16, 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 editor-textbuffer Editor text buffer verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants