mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 07:47:09 +08:00
Fix regression in parse_util_process_extent
Found on a two-line commandline for file in (path base<TAB> echo
This commit is contained in:
parent
1216801474
commit
5b324f8ecb
@ -391,7 +391,7 @@ fn job_or_process_extent(
|
||||
|
||||
let mut result = cmdsub_range.clone();
|
||||
for token in Tokenizer::new(
|
||||
&buff[cmdsub_range],
|
||||
&buff[cmdsub_range.clone()],
|
||||
TOK_ACCEPT_UNFINISHED | TOK_SHOW_COMMENTS,
|
||||
) {
|
||||
let tok_begin = token.offset();
|
||||
@ -408,10 +408,10 @@ fn job_or_process_extent(
|
||||
{
|
||||
if tok_begin >= pos {
|
||||
finished = true;
|
||||
result.end = tok_begin;
|
||||
result.end = cmdsub_range.start + tok_begin;
|
||||
} else {
|
||||
// Statement at cursor might start after this token.
|
||||
result.start = tok_begin + token.length();
|
||||
result.start = cmdsub_range.start + tok_begin + token.length();
|
||||
out_tokens.as_mut().map(|tokens| tokens.clear());
|
||||
}
|
||||
continue; // Do not add this to tokens
|
||||
|
@ -5,7 +5,9 @@ use crate::parse_constants::{
|
||||
ERROR_NOT_ARGV_AT, ERROR_NOT_ARGV_COUNT, ERROR_NOT_ARGV_STAR, ERROR_NOT_PID, ERROR_NOT_STATUS,
|
||||
ERROR_NO_VAR_NAME,
|
||||
};
|
||||
use crate::parse_util::{parse_util_detect_errors, BOOL_AFTER_BACKGROUND_ERROR_MSG};
|
||||
use crate::parse_util::{
|
||||
parse_util_detect_errors, parse_util_process_extent, BOOL_AFTER_BACKGROUND_ERROR_MSG,
|
||||
};
|
||||
use crate::tests::prelude::*;
|
||||
use crate::wchar::prelude::*;
|
||||
|
||||
@ -85,3 +87,16 @@ fn test_error_messages() {
|
||||
BOOL_AFTER_BACKGROUND_ERROR_MSG
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_util_process_extent() {
|
||||
macro_rules! validate {
|
||||
($commandline:literal, $cursor:expr, $expected_range:expr) => {
|
||||
assert_eq!(
|
||||
parse_util_process_extent(L!($commandline), $cursor, None),
|
||||
$expected_range
|
||||
);
|
||||
};
|
||||
}
|
||||
validate!("for file in (path base\necho", 22, 13..22);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user