From adf9340be6801cd5988806fc3051d9da9f367ab4 Mon Sep 17 00:00:00 2001 From: Daniel Imms <2193314+Tyriar@users.noreply.github.com> Date: Tue, 14 Jun 2022 18:19:00 -0700 Subject: [PATCH] Try prevent duplicate placeholder decorations showing This adds these protections: - Placeholders are now always disposed of before a new one is created, this was the main reason for these issues. - Prevent the command started event firing if it has already fired on the same line. Fixes #151228 --- .../common/capabilities/commandDetectionCapability.ts | 6 ++++++ .../contrib/terminal/browser/xterm/decorationAddon.ts | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts b/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts index f9a14291b1f..a67d3fdfc31 100644 --- a/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts +++ b/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts @@ -297,6 +297,12 @@ export class CommandDetectionCapability implements ICommandDetectionCapability { } handleCommandStart(): void { + // Only update the column if the line has already been set + if (this._currentCommand.commandStartMarker?.line === this._terminal.buffer.active.cursorY) { + this._currentCommand.commandStartX = this._terminal.buffer.active.cursorX; + this._logService.debug('CommandDetectionCapability#handleCommandStart', this._currentCommand.commandStartX, this._currentCommand.commandStartMarker?.line); + return; + } if (this._isWindowsPty) { this._handleCommandStartWindows(); return; diff --git a/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts b/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts index 2b346c110b9..b45bfa99f6d 100644 --- a/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts +++ b/src/vs/workbench/contrib/terminal/browser/xterm/decorationAddon.ts @@ -215,14 +215,14 @@ export class DecorationAddon extends Disposable implements ITerminalAddon { if (!decoration) { return undefined; } - + if (beforeCommandExecution) { + this._placeholderDecoration = decoration; + } decoration.onRender(element => { if (element.classList.contains(DecorationSelector.OverviewRuler)) { return; } - if (beforeCommandExecution && !this._placeholderDecoration) { - this._placeholderDecoration = decoration; - } else if (!this._decorations.get(decoration.marker.id)) { + if (!this._decorations.get(decoration.marker.id)) { decoration.onDispose(() => this._decorations.delete(decoration.marker.id)); this._decorations.set(decoration.marker.id, {