Microsoft/vscode

JavaScript: Improve indentation on insert with trailing newline

Open

#85,781 创建于 2019年11月28日

在 GitHub 查看
 (2 评论) (0 反应) (1 负责人)TypeScript (10,221 fork)batch import
editor-autoindenthelp wantedjavascripttree-sitter-autoindent-candidatetypescriptunder-discussion

仓库指标

Star
 (74,848 star)
PR 合并指标
 (平均合并 11小时 43分钟) (30 天内合并 1,000 个 PR)

描述

Let's say I have the following JS snippet:

() => {
  a
}

() => {
  b
}

Now select the entire 'a' part, from the start of line 1 to the start of line 4, i.e. including a trailing newline, and insert it at the start of the line now containing 'b'. The result is this:

() => {
  a
}

() => {
  () => {
    a
  }
    b
}

The 'b' is now over-indented because that line received additional indentation at insert. Expected behavior: the 'b' should remain at its original indentation level. I can confirm this behavior at least for JS and JSON files.


The reason I care is that selecting whole lines with the keyboard is the easiest from start to start, so this kind of pasting is very common in my workflow. I often do Ctrl+C, Ctrl+V, Ctrl+V to duplicate lines; with this bug, this will add two additional indentations to the next line, which is potentially unrelated to the copied lines.

贡献者指南