mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-03-15 23:22:53 +08:00
fish_indent: Fix crash with redirection at the end of the source
This commit is contained in:
parent
cb51b236f3
commit
b5ccacf5b5
@ -614,9 +614,17 @@ impl<'source, 'ast> PrettyPrinterState<'source, 'ast> {
|
||||
|
||||
fn visit_redirection(&mut self, node: &ast::Redirection) {
|
||||
// No space between a redirection operator and its target (#2899).
|
||||
self.emit_text(node.oper.range().unwrap(), GapFlags::default());
|
||||
let Some(orange) = node.oper.range() else {
|
||||
return;
|
||||
};
|
||||
self.emit_text(orange, GapFlags::default());
|
||||
|
||||
// (target is None if the source ends in a `<` or `>`
|
||||
let Some(trange) = node.target.range() else {
|
||||
return;
|
||||
};
|
||||
self.emit_text(
|
||||
node.target.range().unwrap(),
|
||||
trange,
|
||||
GapFlags {
|
||||
skip_space: true,
|
||||
..Default::default()
|
||||
|
@ -435,3 +435,6 @@ echo $status #CHECK: 0
|
||||
|
||||
echo 'PATH={$PATH[echo " "' | $fish_indent --ansi
|
||||
# CHECK: PATH={$PATH[echo " "
|
||||
|
||||
echo a\> | $fish_indent
|
||||
# CHECK: a >
|
||||
|
Loading…
x
Reference in New Issue
Block a user