From 5a4a2e20b2e5a73455eba88036df3ab58551dacd Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Tue, 31 Mar 2026 15:57:04 -0500 Subject: [PATCH 1/7] lsh: fix PowerShell strings - herestring openers must be at EOL, closers must be at BOL - ` is the escape character for strings in this language - single quoted strings do not get escapes at all --- crates/lsh/definitions/powershell.lsh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/crates/lsh/definitions/powershell.lsh b/crates/lsh/definitions/powershell.lsh index ad8f34adadf..9af799f1ec0 100644 --- a/crates/lsh/definitions/powershell.lsh +++ b/crates/lsh/definitions/powershell.lsh @@ -17,21 +17,35 @@ pub fn powershell() { } else if /'/ { loop { yield string; - if /\\./ {} - else if /'/ { yield string; break; } + if /'/ { yield string; break; } await input; } - } else if /@"/ { + } else if /@'\s*$/ { + yield string; loop { + if /.*/ {} yield string; - if /\\./ {} - else if /"@/ { yield string; break; } await input; + if /'@/ { + yield string; + break; + } + } + } else if /@"\s*$/ { + yield string; + loop { + if /.*/ {} + yield string; + await input; + if /"@/ { + yield string; + break; + } } } else if /"/ { loop { yield string; - if /\\./ {} + if /`./ {} else if /"/ { yield string; break; } await input; } From ee7e8f99f648ba6ca5a68eaecdfcfaf7d596a50c Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Tue, 31 Mar 2026 16:09:50 -0500 Subject: [PATCH 2/7] add the invalid token type --- crates/edit/src/buffer/mod.rs | 1 + crates/lsh-bin/src/main.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/crates/edit/src/buffer/mod.rs b/crates/edit/src/buffer/mod.rs index 4ec01f103a7..e337f8b6f4d 100644 --- a/crates/edit/src/buffer/mod.rs +++ b/crates/edit/src/buffer/mod.rs @@ -2150,6 +2150,7 @@ impl TextBuffer { HighlightKind::MarkupList => Some(IndexedColor::BrightBlue), HighlightKind::MarkupStrikethrough => None, HighlightKind::MetaHeader => Some(IndexedColor::BrightBlue), + HighlightKind::Invalid => None, }; let attr = match curr.kind { HighlightKind::MarkupBold => Some(Attributes::Bold), diff --git a/crates/lsh-bin/src/main.rs b/crates/lsh-bin/src/main.rs index 365212bbbb8..49a4d476073 100644 --- a/crates/lsh-bin/src/main.rs +++ b/crates/lsh-bin/src/main.rs @@ -126,6 +126,8 @@ fn run_render(generator: lsh::compiler::Generator, path: &Path) -> anyhow::Resul "markup.strikethrough" => "\x1b[9m", // Strikethrough "meta.header" => "\x1b[94m", // Bright Blue + "invalid" => "\x1b[41;97m", // White on Red + _ => { unknown_kinds.push(hk.identifier.to_string()); "" From e73093ea7f3c4c4ab26ce1ddf54e3b7705855549 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Tue, 31 Mar 2026 16:15:03 -0500 Subject: [PATCH 3/7] Mark invalid herestrings with the new invalid token --- crates/lsh/definitions/powershell.lsh | 36 ++++++++++++++++----------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/crates/lsh/definitions/powershell.lsh b/crates/lsh/definitions/powershell.lsh index 9af799f1ec0..6cb637181f3 100644 --- a/crates/lsh/definitions/powershell.lsh +++ b/crates/lsh/definitions/powershell.lsh @@ -20,27 +20,35 @@ pub fn powershell() { if /'/ { yield string; break; } await input; } - } else if /@'\s*$/ { - yield string; - loop { - if /.*/ {} + } else if /@'/ { + if /\s*$/ { // HereStrings must start at the end of the line yield string; - await input; - if /'@/ { + loop { + if /.*/ {} yield string; - break; + await input; + if /'@/ { + yield string; + break; + } } + } else if /.*$/ { + yield invalid; } - } else if /@"\s*$/ { - yield string; - loop { - if /.*/ {} + } else if /@"/ { + if /\s*$/ { // HereStrings must start at the end of the line yield string; - await input; - if /"@/ { + loop { + if /.*/ {} yield string; - break; + await input; + if /"@/ { + yield string; + break; + } } + } else if /.*$/ { + yield invalid; } } else if /"/ { loop { From 4bbf23492b8a335b73663ae039d9ffc24d57edfe Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Tue, 31 Mar 2026 17:46:23 -0500 Subject: [PATCH 4/7] PR feedback --- crates/lsh/definitions/powershell.lsh | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/lsh/definitions/powershell.lsh b/crates/lsh/definitions/powershell.lsh index 6cb637181f3..2aa56851f7e 100644 --- a/crates/lsh/definitions/powershell.lsh +++ b/crates/lsh/definitions/powershell.lsh @@ -32,8 +32,9 @@ pub fn powershell() { break; } } - } else if /.*$/ { + } else if /.*/ { yield invalid; + return; } } else if /@"/ { if /\s*$/ { // HereStrings must start at the end of the line @@ -47,8 +48,9 @@ pub fn powershell() { break; } } - } else if /.*$/ { + } else if /.*/ { yield invalid; + return; } } else if /"/ { loop { From 90ce1657accb269820076119ecd2ccccacf8f286 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Tue, 31 Mar 2026 17:48:37 -0500 Subject: [PATCH 5/7] Revert "PR feedback" This reverts commit 4bbf23492b8a335b73663ae039d9ffc24d57edfe. --- crates/lsh/definitions/powershell.lsh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/crates/lsh/definitions/powershell.lsh b/crates/lsh/definitions/powershell.lsh index 2aa56851f7e..6cb637181f3 100644 --- a/crates/lsh/definitions/powershell.lsh +++ b/crates/lsh/definitions/powershell.lsh @@ -32,9 +32,8 @@ pub fn powershell() { break; } } - } else if /.*/ { + } else if /.*$/ { yield invalid; - return; } } else if /@"/ { if /\s*$/ { // HereStrings must start at the end of the line @@ -48,9 +47,8 @@ pub fn powershell() { break; } } - } else if /.*/ { + } else if /.*$/ { yield invalid; - return; } } else if /"/ { loop { From b30b9d0d2af6c9069553a9ed2538db08850991b5 Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Tue, 31 Mar 2026 17:48:39 -0500 Subject: [PATCH 6/7] Revert "Mark invalid herestrings with the new invalid token" This reverts commit e73093ea7f3c4c4ab26ce1ddf54e3b7705855549. --- crates/lsh/definitions/powershell.lsh | 36 +++++++++++---------------- 1 file changed, 14 insertions(+), 22 deletions(-) diff --git a/crates/lsh/definitions/powershell.lsh b/crates/lsh/definitions/powershell.lsh index 6cb637181f3..9af799f1ec0 100644 --- a/crates/lsh/definitions/powershell.lsh +++ b/crates/lsh/definitions/powershell.lsh @@ -20,35 +20,27 @@ pub fn powershell() { if /'/ { yield string; break; } await input; } - } else if /@'/ { - if /\s*$/ { // HereStrings must start at the end of the line + } else if /@'\s*$/ { + yield string; + loop { + if /.*/ {} yield string; - loop { - if /.*/ {} + await input; + if /'@/ { yield string; - await input; - if /'@/ { - yield string; - break; - } + break; } - } else if /.*$/ { - yield invalid; } - } else if /@"/ { - if /\s*$/ { // HereStrings must start at the end of the line + } else if /@"\s*$/ { + yield string; + loop { + if /.*/ {} yield string; - loop { - if /.*/ {} + await input; + if /"@/ { yield string; - await input; - if /"@/ { - yield string; - break; - } + break; } - } else if /.*$/ { - yield invalid; } } else if /"/ { loop { From 344cb973fa6dc653c9f7f48b2b1074b38a60fb6f Mon Sep 17 00:00:00 2001 From: "Dustin L. Howett" Date: Tue, 31 Mar 2026 17:48:41 -0500 Subject: [PATCH 7/7] Revert "add the invalid token type" This reverts commit ee7e8f99f648ba6ca5a68eaecdfcfaf7d596a50c. --- crates/edit/src/buffer/mod.rs | 1 - crates/lsh-bin/src/main.rs | 2 -- 2 files changed, 3 deletions(-) diff --git a/crates/edit/src/buffer/mod.rs b/crates/edit/src/buffer/mod.rs index e337f8b6f4d..4ec01f103a7 100644 --- a/crates/edit/src/buffer/mod.rs +++ b/crates/edit/src/buffer/mod.rs @@ -2150,7 +2150,6 @@ impl TextBuffer { HighlightKind::MarkupList => Some(IndexedColor::BrightBlue), HighlightKind::MarkupStrikethrough => None, HighlightKind::MetaHeader => Some(IndexedColor::BrightBlue), - HighlightKind::Invalid => None, }; let attr = match curr.kind { HighlightKind::MarkupBold => Some(Attributes::Bold), diff --git a/crates/lsh-bin/src/main.rs b/crates/lsh-bin/src/main.rs index 49a4d476073..365212bbbb8 100644 --- a/crates/lsh-bin/src/main.rs +++ b/crates/lsh-bin/src/main.rs @@ -126,8 +126,6 @@ fn run_render(generator: lsh::compiler::Generator, path: &Path) -> anyhow::Resul "markup.strikethrough" => "\x1b[9m", // Strikethrough "meta.header" => "\x1b[94m", // Bright Blue - "invalid" => "\x1b[41;97m", // White on Red - _ => { unknown_kinds.push(hk.identifier.to_string()); ""