Преглед на файлове

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) {