mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 15:20:59 +02:00
Fix issue 6596 (#6603)
* Fix issue 6596 * add two unit tests * fix pipe * add cp test * fix test on windows
This commit is contained in:
@ -123,7 +123,8 @@ impl NuCompleter {
|
||||
let offset = working_set.next_span_start();
|
||||
let (mut new_line, alias_offset) = try_find_alias(line.as_bytes(), &working_set);
|
||||
let initial_line = line.to_string();
|
||||
new_line.push(b'a');
|
||||
let alias_total_offset: usize = alias_offset.iter().sum();
|
||||
new_line.insert(alias_total_offset + pos, b'a');
|
||||
let pos = offset + pos;
|
||||
let config = self.engine_state.get_config();
|
||||
|
||||
@ -169,9 +170,10 @@ impl NuCompleter {
|
||||
}
|
||||
};
|
||||
|
||||
// Parses the prefix
|
||||
// Parses the prefix. Completion should look up to the cursor position, not after.
|
||||
let mut prefix = working_set.get_span_contents(flat.0).to_vec();
|
||||
prefix.remove(pos - (flat.0.start - span_offset));
|
||||
let index = pos - (flat.0.start - span_offset);
|
||||
prefix.drain(index..);
|
||||
|
||||
// Variables completion
|
||||
if prefix.starts_with(b"$") || most_left_var.is_some() {
|
||||
|
Reference in New Issue
Block a user