Skip to content

Fix indentation issues when pasting with trailing newline - #182934

Open
Russell Davis (russelldavis) wants to merge 1 commit into
microsoft:mainfrom
russelldavis:fix-indent-on-paste-with-trailing-newline
Open

Russell Davis (russelldavis) wants to merge 1 commit into
microsoft:mainfrom
russelldavis:fix-indent-on-paste-with-trailing-newline

Conversation

@russelldavis

Copy link
Copy Markdown
Contributor

Fixes #85781
Fixes #147223
Fixes #33760
Fixes #65614
Fixes #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

if (startLineNumber !== endLineNumber && selection.endColumn === 1) {
endLineNumber--;
}

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
@russelldavis

Copy link
Copy Markdown
Contributor Author

Peng Lyu (@rebornix) any chance you can take a look at this? It's a simple change that fixes a lot of common indentation issues when pasting. 🙏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment