Fixes autocomplete when using sudo (#8094)

# Description

This PR addresses issue #2047 in order to enable autocomplete
functionality when using sudo for executing commands. I'e done a couple
of auxiliary checks such as ignoring whitespace and the last pipe in
order to determine the last command.

# User-Facing Changes

The only user facing change should be the autocomplete working.

# Tests + Formatting

All tests and formatting pass.

# Screenshots

<img width="454" alt="image"
src="https://user-images.githubusercontent.com/4399118/219404037-6cce4358-68a9-42bb-a09b-2986b10fa6cc.png">

# Suggestions welcome

I still don't know the in's and out's if nushell very well, any
suggestions for improvements are welcome.
This commit is contained in:
alesito85
2023-02-25 00:05:36 +01:00
committed by GitHub
parent e93a8b1d32
commit 7c285750c7
3 changed files with 175 additions and 3 deletions

View File

@ -1007,6 +1007,10 @@ impl EngineState {
.map(|d| d.as_string().unwrap_or_default())
.unwrap_or_default()
}
pub fn get_file_contents(&self) -> &Vec<(Vec<u8>, usize, usize)> {
&self.file_contents
}
}
/// A temporary extension to the global state. This handles bridging between the global state and the
@ -1191,6 +1195,10 @@ impl StateDelta {
pub fn exit_scope(&mut self) {
self.scope.pop();
}
pub fn get_file_contents(&self) -> &Vec<(Vec<u8>, usize, usize)> {
&self.file_contents
}
}
impl<'a> StateWorkingSet<'a> {