Przeglądaj źródła

Use a per-file width for the line number gutter. (#6959)

In in the VSCode extension, use the same width for the per-split line
number gutter across all splits. This makes the visuals more consistent.
Richard Smith 1 miesiąc temu
rodzic
commit
7345f4e860
1 zmienionych plików z 14 dodań i 3 usunięć
  1. 14 3
      utils/vscode/src/extension.ts

+ 14 - 3
utils/vscode/src/extension.ts

@@ -50,6 +50,20 @@ function updateSplitLineNumbers(editor: TextEditor | undefined) {
     }
   }
 
+  // Find the maximum split length to ensure consistent width across all splits
+  let maxSplitLength = 0;
+  for (let s = 0; s < splitStarts.length; s++) {
+    const startLine = splitStarts[s];
+    const endLine = s + 1 < splitStarts.length ? splitStarts[s + 1] : document.lineCount;
+    const splitLength = endLine - startLine - 1;
+    if (splitLength > maxSplitLength) {
+      maxSplitLength = splitLength;
+    }
+  }
+
+  const maxDigits = maxSplitLength > 0 ? maxSplitLength.toString().length : 1;
+  const widthStr = `${maxDigits}ch`;
+
   // Iterate through each split
   for (let s = 0; s < splitStarts.length; s++) {
     const startLine = splitStarts[s];
@@ -59,9 +73,6 @@ function updateSplitLineNumbers(editor: TextEditor | undefined) {
       continue;
     }
 
-    const maxDigits = splitLength.toString().length;
-    const widthStr = `${maxDigits}ch`;
-
     for (let i = startLine + 1; i < endLine; i++) {
       const splitLineNum = i - startLine;
       decorations.push({