From ea00d2b4d6fd3627fe8afbd7b9164d88d9b4a695 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Thu, 24 Apr 2025 16:23:26 +0200 Subject: [PATCH 1/7] Hide overlay predecl logic --- crates/nu-protocol/src/engine/state_working_set.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nu-protocol/src/engine/state_working_set.rs b/crates/nu-protocol/src/engine/state_working_set.rs index a12109f41a..ae32bb86f0 100644 --- a/crates/nu-protocol/src/engine/state_working_set.rs +++ b/crates/nu-protocol/src/engine/state_working_set.rs @@ -207,7 +207,7 @@ impl<'a> StateWorkingSet<'a> { None } - pub fn move_predecls_to_overlay(&mut self) { + fn move_predecls_to_overlay(&mut self) { let predecls: HashMap, DeclId> = self.delta.last_scope_frame_mut().predecls.drain().collect(); From 0c652a4203f781d71002243aaa7b083c882356c9 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Thu, 24 Apr 2025 17:42:39 +0200 Subject: [PATCH 2/7] Remove dead overlay code May not be up to date on how the scoping should be resolved so got to go --- .../src/engine/state_working_set.rs | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/crates/nu-protocol/src/engine/state_working_set.rs b/crates/nu-protocol/src/engine/state_working_set.rs index ae32bb86f0..4f775543e6 100644 --- a/crates/nu-protocol/src/engine/state_working_set.rs +++ b/crates/nu-protocol/src/engine/state_working_set.rs @@ -554,34 +554,6 @@ impl<'a> StateWorkingSet<'a> { None } - pub fn contains_decl_partial_match(&self, name: &[u8]) -> bool { - let mut removed_overlays = vec![]; - - for scope_frame in self.delta.scope.iter().rev() { - for overlay_frame in scope_frame.active_overlays(&mut removed_overlays).rev() { - for decl in &overlay_frame.decls { - if decl.0.starts_with(name) { - return true; - } - } - } - } - - for overlay_frame in self - .permanent_state - .active_overlays(&removed_overlays) - .rev() - { - for decl in &overlay_frame.decls { - if decl.0.starts_with(name) { - return true; - } - } - } - - false - } - pub fn next_var_id(&self) -> VarId { let num_permanent_vars = self.permanent_state.num_vars(); VarId::new(num_permanent_vars + self.delta.vars.len()) @@ -850,20 +822,6 @@ impl<'a> StateWorkingSet<'a> { } } - pub fn has_overlay(&self, name: &[u8]) -> bool { - for scope_frame in self.delta.scope.iter().rev() { - if scope_frame - .overlays - .iter() - .any(|(overlay_name, _)| name == overlay_name) - { - return true; - } - } - - self.permanent_state.has_overlay(name) - } - /// Find the overlay corresponding to `name`. pub fn find_overlay(&self, name: &[u8]) -> Option<&OverlayFrame> { for scope_frame in self.delta.scope.iter().rev() { From dfcc3805122b56db8d70801da313be0e642b1b90 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Thu, 24 Apr 2025 17:43:38 +0200 Subject: [PATCH 3/7] Remove unused helper The `StateWorkingSet::global_span_offset()` is never read in Nushell and unlikely to be used elsewhere remove for now --- crates/nu-protocol/src/engine/state_working_set.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/crates/nu-protocol/src/engine/state_working_set.rs b/crates/nu-protocol/src/engine/state_working_set.rs index 4f775543e6..7ec49e879c 100644 --- a/crates/nu-protocol/src/engine/state_working_set.rs +++ b/crates/nu-protocol/src/engine/state_working_set.rs @@ -313,10 +313,6 @@ impl<'a> StateWorkingSet<'a> { } } - pub fn global_span_offset(&self) -> usize { - self.permanent_state.next_span_start() - } - pub fn files(&self) -> impl Iterator { self.permanent_state.files().chain(self.delta.files.iter()) } From 52e2007be971151f6fc4fd59b04997f9a8c5cea3 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Thu, 24 Apr 2025 17:44:17 +0200 Subject: [PATCH 4/7] Remove dead overlay code from `EngineState` --- crates/nu-protocol/src/engine/engine_state.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index 89572c9a85..e3ccd63fa2 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -357,13 +357,6 @@ impl EngineState { Ok(()) } - pub fn has_overlay(&self, name: &[u8]) -> bool { - self.scope - .overlays - .iter() - .any(|(overlay_name, _)| name == overlay_name) - } - pub fn active_overlay_ids<'a, 'b>( &'b self, removed_overlays: &'a [Vec], From 77cd40d7d98c4fed9151850d79fda2b297c1972a Mon Sep 17 00:00:00 2001 From: sholderbach Date: Thu, 24 Apr 2025 17:50:10 +0200 Subject: [PATCH 5/7] Hide update_plugin_file impl detail This is currently automatically performed as part of `merge_delta` so don't expose it, so nobody tries to call it again. --- crates/nu-protocol/src/engine/engine_state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index e3ccd63fa2..d21393c9b1 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -502,7 +502,7 @@ impl EngineState { } #[cfg(feature = "plugin")] - pub fn update_plugin_file( + fn update_plugin_file( &self, updated_items: Vec, ) -> Result<(), ShellError> { From e26b111a731ac396b48498a6ff5a40eb438d1ccd Mon Sep 17 00:00:00 2001 From: sholderbach Date: Thu, 24 Apr 2025 18:01:53 +0200 Subject: [PATCH 6/7] Hide another overlay internal detail` Only used for `merge_delta` --- crates/nu-protocol/src/engine/engine_state.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index d21393c9b1..91c00a99ee 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -394,7 +394,7 @@ impl EngineState { } /// Translate overlay IDs from other to IDs in self - pub fn translate_overlay_ids(&self, other: &ScopeFrame) -> Vec { + fn translate_overlay_ids(&self, other: &ScopeFrame) -> Vec { let other_names = other.active_overlays.iter().map(|other_id| { &other .overlays From 6150917c5e9da6f2e2d826ac0bc08f4216042385 Mon Sep 17 00:00:00 2001 From: sholderbach Date: Thu, 24 Apr 2025 22:01:46 +0200 Subject: [PATCH 7/7] Fix fmt --- crates/nu-protocol/src/engine/engine_state.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/crates/nu-protocol/src/engine/engine_state.rs b/crates/nu-protocol/src/engine/engine_state.rs index 91c00a99ee..f03e89b948 100644 --- a/crates/nu-protocol/src/engine/engine_state.rs +++ b/crates/nu-protocol/src/engine/engine_state.rs @@ -502,10 +502,7 @@ impl EngineState { } #[cfg(feature = "plugin")] - fn update_plugin_file( - &self, - updated_items: Vec, - ) -> Result<(), ShellError> { + fn update_plugin_file(&self, updated_items: Vec) -> Result<(), ShellError> { // Updating the signatures plugin file with the added signatures use std::fs::File;