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
JavaScript: Improve indentation on insert with trailing newline #85781
Comments
Would something like this be acceptable? On the last paste line, if
Then don't add extra indent? |
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! |
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines on the equivalent code didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines in the same scenarios didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines on the equivalent code didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines on the equivalent code didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines on the equivalent code didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines on the equivalent code didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines on the equivalent code didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines on the equivalent code didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines on the equivalent code didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Fixes microsoft#85781 Fixes microsoft#147223 Fixes microsoft#33760 Fixes microsoft#65614 Fixes microsoft#86301 (Some of the issues above were closed as being limitations of the regex based indentation rules, but this change is able to fix them.) Note that ReindentSelectedLinesAction already does the same thing as this fix (which is what inspired it -- I noticed that running Reindent Selected Lines on the equivalent code didn't have the same issues): see https://github.com/microsoft/vscode/blob/6cbd9e8f3c5a59c5b1170aac8f2b5e9b0b4edfee/src/vs/editor/contrib/indentation/browser/indentation.ts#L390-L392
Let's say I have the following JS snippet:
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:
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.The text was updated successfully, but these errors were encountered: