From 6c8f7acfea5fb2de6fb19055b0910d8264f683ef Mon Sep 17 00:00:00 2001 From: Johannes Rieken Date: Tue, 14 Mar 2023 11:11:19 +0100 Subject: [PATCH] joh/faithful horse (#177065) * better showing of errors * :lipstick: --- .../interactive/browser/interactiveEditor.css | 7 +++++++ .../browser/interactiveEditorWidget.ts | 21 +++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/interactive/browser/interactiveEditor.css b/src/vs/editor/contrib/interactive/browser/interactiveEditor.css index a0c6204bdcfa..ec47503dbd96 100644 --- a/src/vs/editor/contrib/interactive/browser/interactiveEditor.css +++ b/src/vs/editor/contrib/interactive/browser/interactiveEditor.css @@ -112,6 +112,13 @@ top: 0; } +/* message */ + +.monaco-editor .interactive-editor .message { + padding: 6px 8px; + color: var(--vscode-errorForeground); +} + /* decoration styles */ diff --git a/src/vs/editor/contrib/interactive/browser/interactiveEditorWidget.ts b/src/vs/editor/contrib/interactive/browser/interactiveEditorWidget.ts index a934d7a0cbc8..88e0c2199277 100644 --- a/src/vs/editor/contrib/interactive/browser/interactiveEditorWidget.ts +++ b/src/vs/editor/contrib/interactive/browser/interactiveEditorWidget.ts @@ -46,6 +46,7 @@ import { ThemeIcon } from 'vs/base/common/themables'; import { LRUCache } from 'vs/base/common/map'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IBulkEditService } from 'vs/editor/browser/services/bulkEditService'; +import { toErrorMessage } from 'vs/base/common/errorMessage'; interface IHistoryEntry { @@ -74,7 +75,8 @@ class InteractiveEditorWidget { ]), h('div.toolbar@rhsToolbar'), ]), - h('div.progress@progress') + h('div.progress@progress'), + h('div.message@message'), ] ); @@ -231,7 +233,7 @@ class InteractiveEditorWidget { } getHeight(): number { - return this._inputEditor.getContentHeight() + getTotalHeight(this._elements.history); + return this._inputEditor.getContentHeight() + getTotalHeight(this._elements.message) + getTotalHeight(this._elements.history); } updateProgress(show: boolean) { @@ -374,9 +376,20 @@ class InteractiveEditorWidget { reset(this._elements.history); } + showMessage(value: string) { + this._elements.message.innerText = value; + this._onDidChangeHeight.fire(); + } + + clearMessage() { + reset(this._elements.message); + this._onDidChangeHeight.fire(); + } + reset() { this._ctxInputEmpty.reset(); this.clearHistory(); + this.clearMessage(); } focus() { @@ -738,6 +751,8 @@ export class InteractiveEditorController implements IEditorContribution { this._historyOffset = -1; const input = await this._zone.getInput(wholeRange.getEndPosition(), placeholder, value, this._ctsRequest.token); + this._zone.widget.clearMessage(); + if (!input || !input.value) { continue; } @@ -763,6 +778,7 @@ export class InteractiveEditorController implements IEditorContribution { if (!isCancellationError(e)) { this._logService.error('[IE] ERROR during request', provider.debugName); this._logService.error(e); + this._zone.widget.showMessage(toErrorMessage(e)); } } finally { this._ctxHasActiveRequest.set(false); @@ -781,6 +797,7 @@ export class InteractiveEditorController implements IEditorContribution { if (!reply) { this._logService.trace('[IE] NO reply or edits', provider.debugName); value = input.value; + this._zone.widget.showMessage(localize('empty', "No results, tweak your input and try again.")); historyEntry.remove(); continue; }