소스 검색

Clamp minimum valid doc position to 0 (#27461)

GitOrigin-RevId: d531e2b5351b41217ccc8385f8f317cce91a840b
Alf Eaton 1 년 전
부모
커밋
d3668bddec
1개의 변경된 파일과 4개의 추가작업 그리고 0개의 파일을 삭제
  1. 4 0
      services/web/frontend/js/features/source-editor/utils/position.ts

+ 4 - 0
services/web/frontend/js/features/source-editor/utils/position.ts

@@ -5,6 +5,10 @@ export const findValidPosition = (
   lineNumber: number, // 1-indexed
   columnNumber = 0 // 0-indexed
 ): number => {
+  if (lineNumber < 1) {
+    return 0
+  }
+
   const lines = doc.lines
 
   if (lineNumber > lines) {