Skip to content

Commit

Permalink
Command navigation highlight
Browse files Browse the repository at this point in the history
Fixes #46561
  • Loading branch information
Tyriar committed Mar 16, 2022
1 parent 60541eb commit 26e8950
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/vs/workbench/contrib/terminal/browser/media/terminal.css
Original file line number Diff line number Diff line change
Expand Up @@ -417,3 +417,9 @@
.terminal-command-decoration.default {
pointer-events: none;
}

.terminal-scroll-highlight {
left: 0;
right: 0;
border: 1px solid #ffffff;
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import { Disposable } from 'vs/base/common/lifecycle';
import { ICommandTracker } from 'vs/workbench/contrib/terminal/browser/terminal';
import { ICommandDetectionCapability, IPartialCommandDetectionCapability, ITerminalCapabilityStore, TerminalCapability } from 'vs/platform/terminal/common/capabilities/capabilities';
import type { Terminal, IMarker, ITerminalAddon } from 'xterm';
import { timeout } from 'vs/base/common/async';
import { IColorTheme, ICssStyleCollector, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
import { focusBorder } from 'vs/platform/theme/common/colorRegistry';

enum Boundary {
Top,
Expand Down Expand Up @@ -152,6 +155,23 @@ export class CommandTrackerAddon extends Disposable implements ICommandTracker,
line = Math.max(line - Math.floor(this._terminal.rows / 2), 0);
}
this._terminal.scrollToLine(line);
const decoration = this._terminal.registerDecoration({
marker,
width: this._terminal.cols
});
if (decoration) {
let isRendered = false;
decoration.onRender(element => {
if (!isRendered) {
// TODO: Remove when https://github.com/xtermjs/xterm.js/issues/3686 is fixed
if (!element.classList.contains('xterm-decoration-overview-ruler')) {
element.classList.add('terminal-scroll-highlight');
}
}
});
// Number picked to align with symbol highlight in the editor
timeout(350).then(() => decoration.dispose());
}
}

selectToPreviousCommand(): void {
Expand Down Expand Up @@ -332,3 +352,11 @@ export class CommandTrackerAddon extends Disposable implements ICommandTracker,
return this._getCommandMarkers().length;
}
}

registerThemingParticipant((theme: IColorTheme, collector: ICssStyleCollector) => {
const focusBorderColor = theme.getColor(focusBorder);

if (focusBorderColor) {
collector.addRule(`.terminal-scroll-highlight { border-color: ${focusBorderColor.toString()}; } `);
}
});

0 comments on commit 26e8950

Please sign in to comment.