Skip to content

Commit 7bf0f1c

Browse files
authored
Merge pull request #200051 from microsoft/aiday/checkingEffectiveLineCount
Checking that the effectiveLineNumber is valid before accessing the line content
2 parents b1cffad + 7c7c185 commit 7bf0f1c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,20 +203,22 @@ export class LightBulbWidget extends Disposable implements IContentWidget {
203203
};
204204

205205
let effectiveLineNumber = lineNumber;
206+
let effectiveColumnNumber = 1;
206207
if (!lineHasSpace) {
207208
if (lineNumber > 1 && !isFolded(lineNumber - 1)) {
208209
effectiveLineNumber -= 1;
209-
} else if (!isFolded(lineNumber + 1)) {
210+
} else if ((lineNumber < model.getLineCount()) && !isFolded(lineNumber + 1)) {
210211
effectiveLineNumber += 1;
211212
} else if (column * fontInfo.spaceWidth < 22) {
212213
// cannot show lightbulb above/below and showing
213214
// it inline would overlay the cursor...
214215
return this.hide();
215216
}
217+
effectiveColumnNumber = !!model.getLineContent(effectiveLineNumber).match(/^\S\s*$/) ? 2 : 1;
216218
}
217219

218220
this.state = new LightBulbState.Showing(actions, trigger, atPosition, {
219-
position: { lineNumber: effectiveLineNumber, column: !!model.getLineContent(effectiveLineNumber).match(/^\S\s*$/) ? 2 : 1 },
221+
position: { lineNumber: effectiveLineNumber, column: effectiveColumnNumber },
220222
preference: LightBulbWidget._posPref
221223
});
222224
this._editor.layoutContentWidget(this);

0 commit comments

Comments
 (0)