Skip to content

Commit d548002

Browse files
committed
Debug Console: Backspace does not remove extra lines at the end
fixes microsoft#87126
1 parent d42882c commit d548002

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

  • src/vs/workbench/contrib/debug/browser

src/vs/workbench/contrib/debug/browser/repl.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
8989
_serviceBrand: undefined;
9090

9191
private static readonly REFRESH_DELAY = 100; // delay in ms to refresh the repl for new elements to show
92-
private static readonly REPL_INPUT_INITIAL_HEIGHT = 19;
93-
private static readonly REPL_INPUT_MAX_HEIGHT = 170;
92+
private static readonly REPL_INPUT_LINE_HEIGHT = 19;
9493

9594
private history: HistoryNavigator<string>;
9695
private tree!: WorkbenchAsyncDataTree<IDebugSession, IReplElement, FuzzyScore>;
@@ -99,7 +98,7 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
9998
private replInput!: CodeEditorWidget;
10099
private replInputContainer!: HTMLElement;
101100
private dimension!: dom.Dimension;
102-
private replInputHeight: number;
101+
private replInputLineCount = 1;
103102
private model!: ITextModel;
104103
private historyNavigationEnablement!: IContextKey<boolean>;
105104
private scopedInstantiationService!: IInstantiationService;
@@ -123,7 +122,6 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
123122
) {
124123
super(REPL_ID, telemetryService, themeService, storageService);
125124

126-
this.replInputHeight = Repl.REPL_INPUT_INITIAL_HEIGHT;
127125
this.history = new HistoryNavigator(JSON.parse(this.storageService.get(HISTORY_STORAGE_KEY, StorageScope.WORKSPACE, '[]')), 50);
128126
codeEditorService.registerDecorationType(DECORATION_KEY, {});
129127
this.registerListeners();
@@ -303,8 +301,8 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
303301
revealLastElement(this.tree);
304302
this.history.add(this.replInput.getValue());
305303
this.replInput.setValue('');
306-
const shouldRelayout = this.replInputHeight > Repl.REPL_INPUT_INITIAL_HEIGHT;
307-
this.replInputHeight = Repl.REPL_INPUT_INITIAL_HEIGHT;
304+
const shouldRelayout = this.replInputLineCount > 1;
305+
this.replInputLineCount = 1;
308306
if (shouldRelayout) {
309307
// Trigger a layout to shrink a potential multi line input
310308
this.layout(this.dimension);
@@ -330,18 +328,19 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
330328

331329
layout(dimension: dom.Dimension): void {
332330
this.dimension = dimension;
331+
const replInputHeight = Repl.REPL_INPUT_LINE_HEIGHT * this.replInputLineCount;
333332
if (this.tree) {
334333
const lastElementVisible = this.tree.scrollTop + this.tree.renderHeight >= this.tree.scrollHeight;
335-
const treeHeight = dimension.height - this.replInputHeight;
334+
const treeHeight = dimension.height - replInputHeight;
336335
this.tree.getHTMLElement().style.height = `${treeHeight}px`;
337336
this.tree.layout(treeHeight, dimension.width);
338337
if (lastElementVisible) {
339338
revealLastElement(this.tree);
340339
}
341340
}
342-
this.replInputContainer.style.height = `${this.replInputHeight}px`;
341+
this.replInputContainer.style.height = `${replInputHeight}px`;
343342

344-
this.replInput.layout({ width: dimension.width - 20, height: this.replInputHeight });
343+
this.replInput.layout({ width: dimension.width - 20, height: replInputHeight });
345344
}
346345

347346
focus(): void {
@@ -466,16 +465,14 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati
466465

467466
this.replInput = this.scopedInstantiationService.createInstance(CodeEditorWidget, this.replInputContainer, options, getSimpleCodeEditorWidgetOptions());
468467

469-
this._register(this.replInput.onDidScrollChange(e => {
470-
if (!e.scrollHeightChanged) {
471-
return;
472-
}
473-
this.replInputHeight = Math.max(Repl.REPL_INPUT_INITIAL_HEIGHT, Math.min(Repl.REPL_INPUT_MAX_HEIGHT, e.scrollHeight, this.dimension.height));
474-
this.layout(this.dimension);
475-
}));
476468
this._register(this.replInput.onDidChangeModelContent(() => {
477469
const model = this.replInput.getModel();
478470
this.historyNavigationEnablement.set(!!model && model.getValue() === '');
471+
const lineCount = model ? Math.min(10, model.getLineCount()) : 1;
472+
if (lineCount !== this.replInputLineCount) {
473+
this.replInputLineCount = lineCount;
474+
this.layout(this.dimension);
475+
}
479476
}));
480477
// We add the input decoration only when the focus is in the input #61126
481478
this._register(this.replInput.onDidFocusEditorText(() => this.updateInputDecoration()));

0 commit comments

Comments
 (0)