question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Auto save & new line prevents undo from working

See original GitHub issue
  • Version: 1.41.0
  • Commit: 9579eda04fdb3a9bba2750f15193e5fafe16b959
  • Date: 2019-12-11T17:58:38.338Z
  • Electron: 6.1.5
  • Chrome: 76.0.3809.146
  • Node.js: 12.4.0
  • V8: 7.6.303.31-electron.0
  • OS: Darwin x64 19.2.0

Steps to Reproduce:

  1. set "files.trimFinalNewlines": true and "files.autoSave": "afterDelay"; edit: instead set "files.insertFinalNewline": true to follow POSIX conventions
  2. move the caret to the very end of the file
  3. insert a string at the very end of a file
  4. a new line is automatically added
  5. try to undo step 3 will remove the new line, which is then added again

Does this issue occur when all extensions are disabled?: Yes

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:3
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
quassycommented, Jan 18, 2020

I know this is as designed and is what I want, because very line has to have a \n at the end to be POSIX compatible i.e. work well under UNIXoid systems et cetera. I don’t mind seeing it rendered, also changing the setting to false doesn’t prevent the bug.

The bug report is about Undo not working: It’s impossible to undo any input you do on that said last line, because “auto insert newline” is the last undo action and not “paste text” as it should be because it’s the actual last user action.

1reaction
alexdimacommented, Jan 17, 2020

@quassy

"files.insertFinalNewline": true means the file will be saved to disk with a \n as the last character… No matter what the buffer contents are before the save, the file will be saved to disk with \n as the last character (I think there is an exception for empty files, but otherwise, \n is always added at the end of the buffer by a save participant. This is “as designed”.

If you don’t like to see the extra new line, you could use "editor.renderFinalNewline": false

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prevent VSCode auto format on save from removing final ...
I am using the last feature of VSCode called formatOnSave, which is super cool. I have one tiny problem, the formatter tends to...
Read more >
On save new line added to end of file. How stop this?
This bug is STILL present in Windows. I had both unchecked 'Remove trailing blank lines at the end of saved files' and 'Ensure...
Read more >
Disable auto-save in a model-driven app - Microsoft Learn
Learn how to configure autosave for a model-driven app.
Read more >
How do I remove linebreaks in Notepad++? - Super User
It will put in spaces automatically if necessary to prevent words from ... word of the current line and the first word of...
Read more >
Understanding backup and autosave files in AutoCAD
Disabling automatic save prevents AutoCAD from automatically creating .sv$ files while working. In the event of a crash, there will be no ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found