Skip to content

Commit 0902ef2

Browse files
committed
Don't apply partial edits
1 parent 636d984 commit 0902ef2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

apps/vscode/src/providers/format.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,8 +233,17 @@ async function formatBlock(doc: TextDocument, block: TokenMath | TokenCodeBlock,
233233
new Position(edit.range.end.line + block.range.start.line + 1, edit.range.end.character)
234234
);
235235
return new TextEdit(range, edit.newText);
236-
})
237-
.filter(edit => blockRange.contains(edit.range));
236+
});
237+
238+
// Bail if any edit is out of range. We used to filter these edits out but
239+
// this could bork the cell.
240+
if (edits.some(edit => !blockRange.contains(edit.range))) {
241+
window.showInformationMessage(
242+
"Formatting edits were out of range and could not be applied to the code cell."
243+
);
244+
return [];
245+
}
246+
238247
return adjustedEdits;
239248
}
240249
}

0 commit comments

Comments
 (0)