You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JavaScript: Improve indentation on insert with trailing newline #85781
Now select the entire 'a' part, from the start of line 1 to the start of line 4, i.e. including a trailing newline, and insert it at the start of the line now containing 'b'. The result is this:
()=>{a}()=>{()=>{a}b}
The 'b' is now over-indented because that line received additional indentation at insert. Expected behavior: the 'b' should remain at its original indentation level. I can confirm this behavior at least for JS and JSON files.
The reason I care is that selecting whole lines with the keyboard is the easiest from start to start, so this kind of pasting is very common in my workflow. I often do Ctrl+C, Ctrl+V, Ctrl+V to duplicate lines; with this bug, this will add two additional indentations to the next line, which is potentially unrelated to the copied lines.
I think that's consistent with my mental model, that pasting should behave like the following:
do the paste without any auto-indentation
select exactly the text that was pasted
use tab to indent to the level of the insertion position
So in the case that the insertion range ended at the start of the line (your first condition), the selection from 2. would have an empty last line which would not be indented during 3. I don't care about the second condition too much, as it's trailing whitespace that can be auto-removed. So yes, that sounds good!
Activity
jzyrobert commentedon Dec 4, 2019
Would something like this be acceptable?
On the last paste line, if
Then don't add extra indent?
ensko commentedon Dec 4, 2019
I think that's consistent with my mental model, that pasting should behave like the following:
So in the case that the insertion range ended at the start of the line (your first condition), the selection from 2. would have an empty last line which would not be indented during 3. I don't care about the second condition too much, as it's trailing whitespace that can be auto-removed. So yes, that sounds good!
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline