From beefaee1b680251b2eb8aff00620391f15dce23d Mon Sep 17 00:00:00 2001 From: Justin Chen <54879025+justschen@users.noreply.github.com> Date: Thu, 29 Aug 2024 12:02:23 -0700 Subject: [PATCH] fix lightbulb render location (#227138) more lightbulb bugfixes --- .../codeAction/browser/lightBulbWidget.ts | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/vs/editor/contrib/codeAction/browser/lightBulbWidget.ts b/src/vs/editor/contrib/codeAction/browser/lightBulbWidget.ts index 8f0e98d5bf3..bc71291b49e 100644 --- a/src/vs/editor/contrib/codeAction/browser/lightBulbWidget.ts +++ b/src/vs/editor/contrib/codeAction/browser/lightBulbWidget.ts @@ -75,6 +75,14 @@ export class LightBulbWidget extends Disposable implements IContentWidget { private _gutterState: LightBulbState.State = LightBulbState.Hidden; private _iconClasses: string[] = []; + private readonly lightbulbClasses = [ + 'codicon-' + GUTTER_LIGHTBULB_ICON.id, + 'codicon-' + GUTTER_LIGHTBULB_AIFIX_AUTO_FIX_ICON.id, + 'codicon-' + GUTTER_LIGHTBULB_AUTO_FIX_ICON.id, + 'codicon-' + GUTTER_LIGHTBULB_AIFIX_ICON.id, + 'codicon-' + GUTTER_SPARKLE_FILLED_ICON.id + ]; + private _preferredKbLabel?: string; private _quickFixKbLabel?: string; @@ -148,15 +156,8 @@ export class LightBulbWidget extends Disposable implements IContentWidget { })); this._register(this._editor.onMouseDown(async (e: IEditorMouseEvent) => { - const lightbulbClasses = [ - 'codicon-' + GUTTER_LIGHTBULB_ICON.id, - 'codicon-' + GUTTER_LIGHTBULB_AIFIX_AUTO_FIX_ICON.id, - 'codicon-' + GUTTER_LIGHTBULB_AUTO_FIX_ICON.id, - 'codicon-' + GUTTER_LIGHTBULB_AIFIX_ICON.id, - 'codicon-' + GUTTER_SPARKLE_FILLED_ICON.id - ]; - if (!e.target.element || !lightbulbClasses.some(cls => e.target.element && e.target.element.classList.contains(cls))) { + if (!e.target.element || !this.lightbulbClasses.some(cls => e.target.element && e.target.element.classList.contains(cls))) { return; } @@ -247,7 +248,9 @@ export class LightBulbWidget extends Disposable implements IContentWidget { let hasDecoration = false; if (currLineDecorations) { for (const decoration of currLineDecorations) { - if (decoration.options.glyphMarginClassName) { + const glyphClass = decoration.options.glyphMarginClassName; + + if (glyphClass && !this.lightbulbClasses.some(className => glyphClass.includes(className))) { hasDecoration = true; break; }