Skip to content

Commit d09e5fd

Browse files
authored
fix some lightbulb bugs (microsoft#226677)
1 parent e6ab449 commit d09e5fd

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

src/vs/editor/contrib/codeAction/browser/lightBulbWidget.ts

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,12 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
212212
return this.hide();
213213
}
214214

215+
const hasTextFocus = this._editor.hasTextFocus();
216+
if (!hasTextFocus) {
217+
this.gutterHide();
218+
return this.hide();
219+
}
220+
215221
const options = this._editor.getOptions();
216222
if (!options.get(EditorOption.lightbulb).enabled) {
217223
this.gutterHide();
@@ -236,6 +242,18 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
236242
return lineNumber > 2 && this._editor.getTopForLineNumber(lineNumber) === this._editor.getTopForLineNumber(lineNumber - 1);
237243
};
238244

245+
// Check for glyph margin decorations of any kind
246+
const currLineDecorations = this._editor.getLineDecorations(lineNumber);
247+
let hasDecoration = false;
248+
if (currLineDecorations) {
249+
for (const decoration of currLineDecorations) {
250+
if (decoration.options.glyphMarginClassName) {
251+
hasDecoration = true;
252+
break;
253+
}
254+
}
255+
}
256+
239257
let effectiveLineNumber = lineNumber;
240258
let effectiveColumnNumber = 1;
241259
if (!lineHasSpace) {
@@ -253,8 +271,6 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
253271
const currLineEmptyOrIndented = isLineEmptyOrIndented(lineNumber);
254272
const notEmpty = !nextLineEmptyOrIndented && !prevLineEmptyOrIndented;
255273

256-
const currLineDecorations = this._editor.getLineDecorations(lineNumber);
257-
const hasDecoration = !!(currLineDecorations?.length);
258274

259275
// check above and below. if both are blocked, display lightbulb in the gutter.
260276
if (!nextLineEmptyOrIndented && !prevLineEmptyOrIndented && !hasDecoration) {
@@ -275,8 +291,13 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
275291
position: { lineNumber: effectiveLineNumber, column: effectiveColumnNumber },
276292
preference: LightBulbWidget._posPref
277293
});
278-
this.renderGutterLightbub();
279-
return this.hide();
294+
295+
if (hasDecoration) {
296+
this.gutterHide();
297+
} else {
298+
this.renderGutterLightbub();
299+
return this.hide();
300+
}
280301
} else if ((lineNumber < model.getLineCount()) && !isFolded(lineNumber + 1)) {
281302
effectiveLineNumber += 1;
282303
} else if (column * fontInfo.spaceWidth < 22) {

0 commit comments

Comments
 (0)