From aedf712101ddbc83794d8ca7fd4b60b2922135a5 Mon Sep 17 00:00:00 2001 From: Achilleas Kotsis Date: Thu, 9 May 2024 01:12:51 +0300 Subject: [PATCH] Fix tab alignment in .items when using spaces --- src/utils.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 3a53a74..7f3f666 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -63,7 +63,9 @@ export function fillColumns(str: string, finalLength: number): string { } if (editor.options.insertSpaces) { - for (let e = 0; e < tabSize + finalLength - str.length; e++) { + // Extend str with spaces, until the length of finalLength, plus one tab's worth of spaces. + // We need to subtract finalLegth % tabSize to align with the use of the tab key + for (let e = 0; e < tabSize - finalLength % tabSize + finalLength - str.length; e++) { tab += " "; } str += tab;