From f319a40c6424100e7d50fc35a3b6fac0bb4338c3 Mon Sep 17 00:00:00 2001 From: Jacob Kim Date: Fri, 25 Jul 2025 10:21:16 -0700 Subject: [PATCH] refactor: calculate document content separately --- extensions/vscode/src/commands.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extensions/vscode/src/commands.ts b/extensions/vscode/src/commands.ts index 70a602a0f..4c00fee06 100644 --- a/extensions/vscode/src/commands.ts +++ b/extensions/vscode/src/commands.ts @@ -829,6 +829,8 @@ const getCommandsMap: ( return; } + const documentContent = editor.document.getText(); + // Calculate the editable region boundaries around the current cursor position/ const editableRegionStartLine = Math.max( currentPosition.line - NEXT_EDIT_EDITABLE_REGION_TOP_MARGIN, @@ -840,8 +842,7 @@ const getCommandsMap: ( ); // Get the current text in the editable region. - const oldEditRangeSlice = editor.document - .getText() + const oldEditRangeSlice = documentContent .split("\n") .slice(editableRegionStartLine, editableRegionEndLine + 1) .join("\n");