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

Fix indentation issues when pasting with trailing newline #182934

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

russelldavis
Copy link
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
Contributor Author

@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. 🙏

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