diff --git a/utils/vscode/src/extension.ts b/utils/vscode/src/extension.ts index 442036810b16..fd178cd2a811 100644 --- a/utils/vscode/src/extension.ts +++ b/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({