mirror of
https://github.com/fish-shell/fish-shell
synced 2025-01-27 20:25:12 +00:00
Fix parse_util_process_extent including too much on the left
This commit is contained in:
parent
83b0294fc9
commit
3fcc6482cb
2 changed files with 7 additions and 1 deletions
|
@ -401,6 +401,7 @@ fn job_or_process_extent(
|
|||
let pos = cursor_pos - cmdsub_range.start;
|
||||
|
||||
let mut result = cmdsub_range.clone();
|
||||
let mut found_start = false;
|
||||
for token in Tokenizer::new(
|
||||
&buff[cmdsub_range.clone()],
|
||||
TOK_ACCEPT_UNFINISHED | TOK_SHOW_COMMENTS,
|
||||
|
@ -422,13 +423,17 @@ fn job_or_process_extent(
|
|||
result.end = cmdsub_range.start + tok_begin;
|
||||
} else {
|
||||
// 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());
|
||||
}
|
||||
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));
|
||||
}
|
||||
result
|
||||
|
|
|
@ -102,6 +102,7 @@ fn test_parse_util_process_extent() {
|
|||
};
|
||||
}
|
||||
validate!("for file in (path base\necho", 22, 13..22);
|
||||
validate!("begin\n\n\nec", 10, 8..10);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue