Skip to content

Commit 8a9ede8

Browse files
committed
fix: handle lineCount=0
1 parent 3202b3a commit 8a9ede8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/notebooks/deepnote/deepnoteInputBlockEditProtection.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,10 @@ export class DeepnoteInputBlockEditProtection implements Disposable {
119119
// Only revert if content actually changed
120120
if (cell.document.getText() !== correctContent) {
121121
const edit = new WorkspaceEdit();
122+
const lastLine = Math.max(0, cell.document.lineCount - 1);
122123
const fullRange = new Range(
123124
new Position(0, 0),
124-
new Position(cell.document.lineCount - 1, cell.document.lineAt(cell.document.lineCount - 1).text.length)
125+
new Position(lastLine, cell.document.lineAt(lastLine).text.length)
125126
);
126127
edit.replace(cell.document.uri, fullRange, correctContent);
127128
await workspace.applyEdit(edit);

0 commit comments

Comments
 (0)