mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 04:45:04 +02:00
Finish up completions
This commit is contained in:
@ -123,6 +123,24 @@ impl EngineState {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<Vec<u8>> {
|
||||
let mut output = vec![];
|
||||
|
||||
for scope in self.scope.iter().rev() {
|
||||
for decl in &scope.decls {
|
||||
if decl.0.starts_with(name) {
|
||||
output.push(decl.0.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
pub fn get_span_contents(&self, span: Span) -> &[u8] {
|
||||
&self.file_contents[span.start..span.end]
|
||||
}
|
||||
|
||||
pub fn get_var(&self, var_id: VarId) -> &Type {
|
||||
self.vars
|
||||
.get(var_id)
|
||||
@ -496,6 +514,24 @@ impl<'a> StateWorkingSet<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_commands_by_prefix(&self, name: &[u8]) -> Vec<Vec<u8>> {
|
||||
let mut output = vec![];
|
||||
|
||||
for scope in self.delta.scope.iter().rev() {
|
||||
for decl in &scope.decls {
|
||||
if decl.0.starts_with(name) {
|
||||
output.push(decl.0.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut permanent = self.permanent_state.find_commands_by_prefix(name);
|
||||
|
||||
output.append(&mut permanent);
|
||||
|
||||
output
|
||||
}
|
||||
|
||||
pub fn get_block(&self, block_id: BlockId) -> &Block {
|
||||
let num_permanent_blocks = self.permanent_state.num_blocks();
|
||||
if block_id < num_permanent_blocks {
|
||||
|
Reference in New Issue
Block a user