Skip to content

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

Description

@jzyrobert

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

Activity

  1. vscodebot commented on Dec 4, 2019

    @vscodebot

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

  2. rebornix commented on Dec 6, 2019

    @rebornix
    Contributor

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

  3. added
    editor-autoindent
    polish
    on Dec 6, 2019
  4. jzyrobert commented on Dec 6, 2019

    @jzyrobert
    ContributorAuthor

    Peng Lyu (@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
  5. added
    under-discussion
    on Nov 3, 2020
  6. added 3 commits that reference this issue on May 19, 2023
    dd67538
    3b8024e
    b733589
  7. added a commit that references this issue on Jun 9, 2023
    3ae10ad
  8. added a commit that references this issue on Jul 18, 2023
    835deb4
  9. added 5 commits that reference this issue on Sep 30, 2023
    38fa637
    886e568
    6ed6108
    1e2c3d3
    8b96807
  10. added
    javascript
    typescript
    on Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

editor-autoindentjavascriptpolishtree-sitter-autoindent-candidatetypescriptunder-discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions