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

Should pasting newline with auto-indent move the cursor + inconsistencies when pasting newlines #86301

Open
jzyrobert opened this issue Dec 4, 2019 · 3 comments · May be fixed by #182934
Open
Assignees
Labels
editor-autoindent Editor auto indentation issues javascript JavaScript support issues on-unit-test polish Cleanup and polish issue typescript Typescript support issues under-discussion Issue is under discussion for relevance, priority, approach

Comments

@jzyrobert
Copy link
Contributor

Issue Type: Bug

  • Have an indent block, eg:
() => {

}
  • Paste something with a trailing newline
  • Expected: The newline is indented and your cursor starts at the right indent position
() => {
	() => {
		a
	}
	<- Cursor is here
}
  • Actual: The newline is indented but your cursor stays at the beginning of the line
() => {
	() => {
		a
	}
<- Cursor is here <indent after>	
}

Also when pasting content with a trailing newline, only pastes with 2+ lines (that isn't already correctly indented) end up indenting the last newline.

() => {
	() => {}
<- Cursor is here, no indent
}
() => {
	() => {

	}
<- Cursor is here <indent after>
}
() => {
	() => {

	}
<- Cursor is here, no indent (as pasted content already had correct indent)
}

VS Code version: Code 1.40.2 (f359dd6, 2019-11-25T14:54:45.096Z)
OS version: Windows_NT x64 10.0.19033

@vscodebot
Copy link

vscodebot bot commented Dec 4, 2019

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@rebornix
Copy link
Member

rebornix commented Dec 6, 2019

Auto Indent on Paste is based on indentation rules, which are not sound. You can currently disable this particular auto indent feature by setting editor.autoIndent: advanced ./

@rebornix rebornix added editor-autoindent Editor auto indentation issues polish Cleanup and polish issue labels Dec 6, 2019
@jzyrobert
Copy link
Contributor Author

@rebornix I can try and work on it.
What do you think is the more consistent way?

  • Don't indent trailing newlines
  • Always indent trailing newlines

@rebornix rebornix added the under-discussion Issue is under discussion for relevance, priority, approach label Nov 3, 2020
russelldavis added a commit to russelldavis/vscode that referenced this issue May 19, 2023
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
russelldavis added a commit to russelldavis/vscode that referenced this issue May 19, 2023
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 added a commit to russelldavis/vscode that referenced this issue May 22, 2023
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
russelldavis added a commit to russelldavis/vscode that referenced this issue Jun 9, 2023
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
russelldavis added a commit to russelldavis/vscode that referenced this issue Jul 18, 2023
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
russelldavis added a commit to russelldavis/vscode that referenced this issue Sep 30, 2023
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
russelldavis added a commit to russelldavis/vscode that referenced this issue Oct 2, 2023
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
russelldavis added a commit to russelldavis/vscode that referenced this issue Oct 3, 2023
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
russelldavis added a commit to russelldavis/vscode that referenced this issue Oct 7, 2023
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
russelldavis added a commit to russelldavis/vscode that referenced this issue Oct 12, 2023
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
@aiday-mar aiday-mar assigned aiday-mar and unassigned rebornix Mar 8, 2024
@aiday-mar aiday-mar added javascript JavaScript support issues typescript Typescript support issues labels Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-autoindent Editor auto indentation issues javascript JavaScript support issues on-unit-test polish Cleanup and polish issue typescript Typescript support issues under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants