From 70df5a639cfe994ca3ad18f1cfe4f150be51d126 Mon Sep 17 00:00:00 2001 From: Kyle Loveless Date: Thu, 14 Nov 2024 09:47:06 -0600 Subject: [PATCH] switch .replaceAll.trimEnd with regex replace --- main.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/main.ts b/main.ts index cc8bdc9..3f08fc7 100644 --- a/main.ts +++ b/main.ts @@ -227,7 +227,12 @@ function editorOpen(filename: string) { console.log(`filename: ${filename}`); e.filename = filename; const data = Deno.readFileSync(filename); - const contents = decoder.decode(data).replaceAll("\r", "").trimEnd(); + // /\s+$/ + // \s+ -> matches one or more whitespace characters, including spaces, tabs, + // newlines, and carraige returns + // $ -> anchors the match to the end of the string + // '' -> replaces the matched whitespace chars with an empty string + const contents = decoder.decode(data).replace(/\s+$/, ""); const lines = contents.split("\n"); let i = 0;