From 445406d25185677bb084318da05f9e6f061953b4 Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 10 Jan 2024 19:33:47 +0100 Subject: [PATCH] fish_indent: Don't panic for gap text It should be fine to just write the space out here. This one triggered by `echo b\|\{ | ./fish_indent` --- fish-rust/src/fish_indent.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fish-rust/src/fish_indent.rs b/fish-rust/src/fish_indent.rs index 2a3011878..c8a36938d 100755 --- a/fish-rust/src/fish_indent.rs +++ b/fish-rust/src/fish_indent.rs @@ -446,8 +446,9 @@ fn emit_gap_text(&mut self, range: SourceRange, flags: GapFlags) -> bool { self.emit_newline(); } } else { - panic!("Gap text should only have comments and newlines - instead found token type {:?} with text: {}", - tok.type_, tok_text); + // Anything else we write a space. + self.emit_space_or_indent(GapFlags::default()); + self.output.push_utfstr(tok_text); } } if needs_nl {