mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-07 18:47:15 +08:00
Fix parse_util_process_extent including too much on the left
This commit is contained in:
parent
83b0294fc9
commit
3fcc6482cb
|
@ -401,6 +401,7 @@ fn job_or_process_extent(
|
||||||
let pos = cursor_pos - cmdsub_range.start;
|
let pos = cursor_pos - cmdsub_range.start;
|
||||||
|
|
||||||
let mut result = cmdsub_range.clone();
|
let mut result = cmdsub_range.clone();
|
||||||
|
let mut found_start = false;
|
||||||
for token in Tokenizer::new(
|
for token in Tokenizer::new(
|
||||||
&buff[cmdsub_range.clone()],
|
&buff[cmdsub_range.clone()],
|
||||||
TOK_ACCEPT_UNFINISHED | TOK_SHOW_COMMENTS,
|
TOK_ACCEPT_UNFINISHED | TOK_SHOW_COMMENTS,
|
||||||
|
@ -422,13 +423,17 @@ fn job_or_process_extent(
|
||||||
result.end = cmdsub_range.start + tok_begin;
|
result.end = cmdsub_range.start + tok_begin;
|
||||||
} else {
|
} else {
|
||||||
// Statement at cursor might start after this token.
|
// Statement at cursor might start after this token.
|
||||||
result.start = cmdsub_range.start + tok_begin + token.length();
|
found_start = false;
|
||||||
out_tokens.as_mut().map(|tokens| tokens.clear());
|
out_tokens.as_mut().map(|tokens| tokens.clear());
|
||||||
}
|
}
|
||||||
continue; // Do not add this to tokens
|
continue; // Do not add this to tokens
|
||||||
}
|
}
|
||||||
_ => (),
|
_ => (),
|
||||||
}
|
}
|
||||||
|
if !found_start {
|
||||||
|
result.start = cmdsub_range.start + tok_begin;
|
||||||
|
found_start = true;
|
||||||
|
}
|
||||||
out_tokens.as_mut().map(|tokens| tokens.push(token));
|
out_tokens.as_mut().map(|tokens| tokens.push(token));
|
||||||
}
|
}
|
||||||
result
|
result
|
||||||
|
|
|
@ -102,6 +102,7 @@ fn test_parse_util_process_extent() {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
validate!("for file in (path base\necho", 22, 13..22);
|
validate!("for file in (path base\necho", 22, 13..22);
|
||||||
|
validate!("begin\n\n\nec", 10, 8..10);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user