2026-04-29    2026-04-29    175 字  1 分钟

The note is generated by Opus-4.7

Problem

When using the vscode-neovim extension, the VSCode Output panel automatically reveals and steals focus from the terminal whenever Neovim logs appear.

Root Cause

In src/messages_manager.ts, the extension calls this.channel.show(true) (which reveals and focuses the Output panel) whenever the number of lines in a Neovim message exceeds cmdheight:

1
2
3
4
5
6
const lineCount = outputMsg.split("\n").length;
const cmdheight = (await this.main.client.getOption("cmdheight")) as number;

if (lineCount > cmdheight) {
  this.channel.show(true);
}
  • cmdheight=0 (default when ext_messages is enabled): every message exceeds 0 lines → Output panel steals focus on every log
  • cmdheight=1: only messages with more than 1 line trigger the Output panel
  • cmdheight=N: only messages exceeding N lines trigger it

Fix

Set cmdheight=1 in the VSCode-specific Neovim config (~/.config/nvim/lua/plugins/vscode.lua):

1
2
3
4
5
options = {
  opt = {
    cmdheight = 1,
  },
},

Result

Single-line Neovim logs no longer cause the Output panel to steal focus. Multi-line messages may still trigger it, but those are rare in normal usage.

Reference