fish_indent: Another crash

NUL at the end, which is now ignored.

Not *great*, but better than crashing.
This commit is contained in:
Fabian Boehm 2024-01-10 20:56:13 +01:00
parent 50acc4f4de
commit 2e14c32c5e
2 changed files with 5 additions and 2 deletions

View file

@ -647,11 +647,11 @@ impl<'source, 'ast> PrettyPrinterState<'source, 'ast> {
// # something
// cmd2
// Treat it as gap text.
if node.range().unwrap().length() == 0 {
let Some(range) = node.range() else { return; };
if range.length() == 0 {
return;
}
let flags = self.gap_text_flags_before_node(node);
let range = node.range().unwrap();
self.current_indent = self.indent(range.start());
let added_newline = self.emit_gap_text_before(range, flags);
let mut gap_range = range;

View file

@ -446,3 +446,6 @@ echo b\|\{ | $fish_indent
echo "\'\\\\\x00\'" | string unescape | $fish_indent | string escape
# CHECK: \'\\\x00\'
echo '\"\"\|\x00' | string unescape | $fish_indent | string unescape
# CHECK: |