mirror of
https://github.com/nushell/nushell.git
synced 2025-08-19 07:01:30 +02:00
refactor(completion, lsp): include decl_id in suggetion_kind for later usage (#15536)
# Description Should be more performant, calling for `find_decl` by name for all entries is generally a heavy op. # User-Facing Changes NA # Tests + Formatting # After Submitting
This commit is contained in:
@@ -731,18 +731,19 @@ impl EngineState {
|
||||
&self,
|
||||
mut predicate: impl FnMut(&[u8]) -> bool,
|
||||
ignore_deprecated: bool,
|
||||
) -> Vec<(Vec<u8>, Option<String>, CommandType)> {
|
||||
) -> Vec<(DeclId, Vec<u8>, Option<String>, CommandType)> {
|
||||
let mut output = vec![];
|
||||
|
||||
for overlay_frame in self.active_overlays(&[]).rev() {
|
||||
for decl in &overlay_frame.decls {
|
||||
if overlay_frame.visibility.is_decl_id_visible(decl.1) && predicate(decl.0) {
|
||||
let command = self.get_decl(*decl.1);
|
||||
for (name, decl_id) in &overlay_frame.decls {
|
||||
if overlay_frame.visibility.is_decl_id_visible(decl_id) && predicate(name) {
|
||||
let command = self.get_decl(*decl_id);
|
||||
if ignore_deprecated && command.signature().category == Category::Removed {
|
||||
continue;
|
||||
}
|
||||
output.push((
|
||||
decl.0.clone(),
|
||||
*decl_id,
|
||||
name.clone(),
|
||||
Some(command.description().to_string()),
|
||||
command.command_type(),
|
||||
));
|
||||
|
@@ -780,21 +780,22 @@ impl<'a> StateWorkingSet<'a> {
|
||||
&self,
|
||||
mut predicate: impl FnMut(&[u8]) -> bool,
|
||||
ignore_deprecated: bool,
|
||||
) -> Vec<(Vec<u8>, Option<String>, CommandType)> {
|
||||
) -> Vec<(DeclId, Vec<u8>, Option<String>, CommandType)> {
|
||||
let mut output = vec![];
|
||||
|
||||
for scope_frame in self.delta.scope.iter().rev() {
|
||||
for overlay_id in scope_frame.active_overlays.iter().rev() {
|
||||
let overlay_frame = scope_frame.get_overlay(*overlay_id);
|
||||
|
||||
for decl in &overlay_frame.decls {
|
||||
if overlay_frame.visibility.is_decl_id_visible(decl.1) && predicate(decl.0) {
|
||||
let command = self.get_decl(*decl.1);
|
||||
for (name, decl_id) in &overlay_frame.decls {
|
||||
if overlay_frame.visibility.is_decl_id_visible(decl_id) && predicate(name) {
|
||||
let command = self.get_decl(*decl_id);
|
||||
if ignore_deprecated && command.signature().category == Category::Removed {
|
||||
continue;
|
||||
}
|
||||
output.push((
|
||||
decl.0.clone(),
|
||||
*decl_id,
|
||||
name.clone(),
|
||||
Some(command.description().to_string()),
|
||||
command.command_type(),
|
||||
));
|
||||
|
Reference in New Issue
Block a user