fix out of range error (#4931)

* fix out of range error

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* remove console logs

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add a regression test

Signed-off-by: Jess Frazelle <github@jessfraz.com>

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2025-01-06 17:18:58 -08:00
committed by GitHub
parent d9c2dd376e
commit 7e54f08778
4 changed files with 112 additions and 18 deletions

View File

@ -323,7 +323,8 @@ export function handleSelectionBatch({
resetAndSetEngineEntitySelectionCmds(selectionToEngine)
selections.graphSelections.forEach(({ codeRef }) => {
if (codeRef.range?.[1]) {
ranges.push(EditorSelection.cursor(codeRef.range[1]))
const safeEnd = Math.min(codeRef.range[1], codeManager.code.length)
ranges.push(EditorSelection.cursor(safeEnd))
}
})
if (ranges.length)