Skip to content

Commit c293d5a

Browse files
authored
fix lightbulb jumping in the gutter (but like not the trash) (microsoft#227022)
* fix for flickering lightbulb * second fix * remove console log
1 parent 59b2709 commit c293d5a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,12 @@ export class CodeActionController extends Disposable implements IEditorContribut
180180
return;
181181
}
182182

183+
184+
const selection = this._editor.getSelection();
185+
if (selection?.startLineNumber !== newState.position.lineNumber) {
186+
return;
187+
}
188+
183189
this._lightBulbWidget.value?.update(actions, newState.trigger, newState.position);
184190

185191
if (newState.trigger.type === CodeActionTriggerType.Invoke) {

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,6 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
271271
const currLineEmptyOrIndented = isLineEmptyOrIndented(lineNumber);
272272
const notEmpty = !nextLineEmptyOrIndented && !prevLineEmptyOrIndented;
273273

274-
275274
// check above and below. if both are blocked, display lightbulb in the gutter.
276275
if (!nextLineEmptyOrIndented && !prevLineEmptyOrIndented && !hasDecoration) {
277276
this.gutterState = new LightBulbState.Showing(actions, trigger, atPosition, {
@@ -280,7 +279,7 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
280279
});
281280
this.renderGutterLightbub();
282281
return this.hide();
283-
} else if (prevLineEmptyOrIndented || endLine || (notEmpty && !currLineEmptyOrIndented)) {
282+
} else if (prevLineEmptyOrIndented || endLine || (prevLineEmptyOrIndented && !currLineEmptyOrIndented)) {
284283
effectiveLineNumber -= 1;
285284
} else if (nextLineEmptyOrIndented || (notEmpty && currLineEmptyOrIndented)) {
286285
effectiveLineNumber += 1;

0 commit comments

Comments
 (0)