mirror of
https://github.com/microsoft/vscode.git
synced 2026-06-06 07:35:52 +01:00
The provideAltTextQuickFix method calls document.lineAt(range.start.line) without validating that the line number is within bounds. When the document is modified between when VS Code computes the range and when the code action provider executes, an out-of-bounds line number causes 'Illegal value for `line`' to be thrown. Add a bounds check before calling lineAt() so the method returns early instead of throwing. Co-authored-by: vs-code-engineering[bot] <122617954+vs-code-engineering[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
c298595b23
commit
f5a135b01f
@@ -136,6 +136,9 @@ export class QuickFixesProvider implements vscode.CodeActionProvider {
|
||||
}
|
||||
|
||||
private provideAltTextQuickFix(document: vscode.TextDocument, range: vscode.Range): ImageCodeAction | undefined {
|
||||
if (range.start.line < 0 || range.start.line >= document.lineCount) {
|
||||
return;
|
||||
}
|
||||
const currentLine = document.lineAt(range.start.line).text;
|
||||
const generateImagePath = extractImageAttributes(currentLine);
|
||||
const refineImagePath = extractImageAttributes(currentLine, true);
|
||||
|
||||
Reference in New Issue
Block a user