microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.24k stars 28.88k forks source link

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

Open jzyrobert opened 4 years ago

jzyrobert commented 4 years ago

Issue Type: Bug

}

- 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
}


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 }

() => { () => {

}

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



VS Code version: Code 1.40.2 (f359dd69833dd8800b54d458f6d37ab7c78df520, 2019-11-25T14:54:45.096Z)
OS version: Windows_NT x64 10.0.19033
vscodebot[bot] commented 4 years ago

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

rebornix commented 4 years ago

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 ./

jzyrobert commented 4 years ago

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