Skip to content

Commit e86cdd8

Browse files
committed
refactoring the code
1 parent 4635c35 commit e86cdd8

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/vs/editor/contrib/hover/browser/contentHover.ts

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ export class ContentHoverController extends Disposable {
195195

196196
private _setCurrentResult(hoverResult: HoverResult | null): void {
197197
if (this._currentResult === hoverResult) {
198-
if (hoverResult === null && !this._widget.isFocused) {
199-
this._widget.hide();
200-
}
198+
// avoid updating the DOM to avoid resetting the user selection
201199
return;
202200
}
203201
if (hoverResult && hoverResult.messages.length === 0) {
@@ -207,9 +205,6 @@ export class ContentHoverController extends Disposable {
207205
if (this._currentResult) {
208206
this._renderMessages(this._currentResult.anchor, this._currentResult.messages);
209207
} else {
210-
if (this._widget.isFocused) {
211-
return;
212-
}
213208
this._widget.hide();
214209
}
215210
}
@@ -232,6 +227,10 @@ export class ContentHoverController extends Disposable {
232227
return this._widget.isVisible;
233228
}
234229

230+
public isFocused(): boolean {
231+
return this._widget.isFocused;
232+
}
233+
235234
public containsNode(node: Node | null | undefined): boolean {
236235
return (node ? this._widget.getDomNode().contains(node) : false);
237236
}
@@ -264,7 +263,9 @@ export class ContentHoverController extends Disposable {
264263
return;
265264
}
266265
}
267-
266+
if (hoverResult.messages.length === 0 && this._widget.isFocused) {
267+
return;
268+
}
268269
this._setCurrentResult(hoverResult);
269270
}
270271

@@ -735,7 +736,10 @@ export class ContentHoverWidget extends ResizableContentWidget {
735736
}
736737

737738
public hide(): void {
738-
const stoleFocus = this._visibleData?.stoleFocus || this._hoverFocusedKey.get();
739+
if (!this._visibleData) {
740+
return;
741+
}
742+
const stoleFocus = this._visibleData.stoleFocus || this._hoverFocusedKey.get();
739743
this._setHoverData(undefined);
740744
this._resizableNode.maxSize = new dom.Dimension(Infinity, Infinity);
741745
this._resizableNode.clearSashHoverState();

0 commit comments

Comments
 (0)