From b03b438383b85b30e7fee2cba00dde97d8029b7c Mon Sep 17 00:00:00 2001 From: Pavel Nikolaev Date: Mon, 2 Oct 2023 15:34:12 +0300 Subject: [PATCH 1/3] 12970 Fixes hover widget jumping --- .../src/browser/editor/debug-hover-widget.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/debug/src/browser/editor/debug-hover-widget.ts b/packages/debug/src/browser/editor/debug-hover-widget.ts index 22f30493899f7..d47e8d3fad706 100644 --- a/packages/debug/src/browser/editor/debug-hover-widget.ts +++ b/packages/debug/src/browser/editor/debug-hover-widget.ts @@ -203,6 +203,22 @@ export class DebugHoverWidget extends SourceTreeWidget implements monaco.editor. this.hide(); return; } + const lineContent = this.editor + .getControl() + .getModel()! + .getLineContent(this.options.selection.startLineNumber); + const startColumn = + lineContent.indexOf( + matchingExpression, + this.options.selection.startColumn - matchingExpression.length + ) + 1; + const endColumn = startColumn + matchingExpression.length; + this.options.selection = new monaco.Range( + this.options.selection.startLineNumber, + startColumn, + this.options.selection.startLineNumber, + endColumn + ); const toFocus = new DisposableCollection(); if (this.options.focus === true) { toFocus.push(this.model.onNodeRefreshed(() => { From 63d737207597c58af98d932a870eac94035c04a1 Mon Sep 17 00:00:00 2001 From: Pavel Nikolaev Date: Mon, 2 Oct 2023 15:45:55 +0300 Subject: [PATCH 2/3] 12970 Fixes variable name --- packages/debug/src/browser/editor/debug-hover-widget.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/debug/src/browser/editor/debug-hover-widget.ts b/packages/debug/src/browser/editor/debug-hover-widget.ts index d47e8d3fad706..124e0d638dc19 100644 --- a/packages/debug/src/browser/editor/debug-hover-widget.ts +++ b/packages/debug/src/browser/editor/debug-hover-widget.ts @@ -203,12 +203,12 @@ export class DebugHoverWidget extends SourceTreeWidget implements monaco.editor. this.hide(); return; } - const lineContent = this.editor + const expressionLineContent = this.editor .getControl() .getModel()! .getLineContent(this.options.selection.startLineNumber); const startColumn = - lineContent.indexOf( + expressionLineContent.indexOf( matchingExpression, this.options.selection.startColumn - matchingExpression.length ) + 1; From c0341089283386b2531ce210a1425da6bd6e3506 Mon Sep 17 00:00:00 2001 From: Pavel Nikolaev Date: Wed, 11 Oct 2023 16:40:37 +0300 Subject: [PATCH 3/3] 12970 Fixed behavior if there is a pluginExpressionProvider --- .../src/browser/editor/debug-hover-widget.ts | 34 ++++++++++--------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/packages/debug/src/browser/editor/debug-hover-widget.ts b/packages/debug/src/browser/editor/debug-hover-widget.ts index 124e0d638dc19..9c0276a407af7 100644 --- a/packages/debug/src/browser/editor/debug-hover-widget.ts +++ b/packages/debug/src/browser/editor/debug-hover-widget.ts @@ -197,28 +197,30 @@ export class DebugHoverWidget extends SourceTreeWidget implements monaco.editor. } } else { // use fallback if no provider was registered matchingExpression = this.expressionProvider.get(this.editor.getControl().getModel()!, options.selection); + if (matchingExpression) { + const expressionLineContent = this.editor + .getControl() + .getModel()! + .getLineContent(this.options.selection.startLineNumber); + const startColumn = + expressionLineContent.indexOf( + matchingExpression, + this.options.selection.startColumn - matchingExpression.length + ) + 1; + const endColumn = startColumn + matchingExpression.length; + this.options.selection = new monaco.Range( + this.options.selection.startLineNumber, + startColumn, + this.options.selection.startLineNumber, + endColumn + ); + } } if (!matchingExpression) { this.hide(); return; } - const expressionLineContent = this.editor - .getControl() - .getModel()! - .getLineContent(this.options.selection.startLineNumber); - const startColumn = - expressionLineContent.indexOf( - matchingExpression, - this.options.selection.startColumn - matchingExpression.length - ) + 1; - const endColumn = startColumn + matchingExpression.length; - this.options.selection = new monaco.Range( - this.options.selection.startLineNumber, - startColumn, - this.options.selection.startLineNumber, - endColumn - ); const toFocus = new DisposableCollection(); if (this.options.focus === true) { toFocus.push(this.model.onNodeRefreshed(() => {