From a642f8ef7ecd55379df91922decba955ba6b797b Mon Sep 17 00:00:00 2001 From: tolelom <98kimsungmin@naver.com> Date: Thu, 26 Mar 2026 09:52:53 +0900 Subject: [PATCH] fix(editor): address code review issues in dock module MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - debug_assert → assert for empty tabs invariant - tabs.len() - 1 → saturating_sub(1) to prevent underflow - Add #[allow(dead_code)] for scaffolded structs/constants Co-Authored-By: Claude Opus 4.6 (1M context) --- crates/voltex_editor/src/dock.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/crates/voltex_editor/src/dock.rs b/crates/voltex_editor/src/dock.rs index f757b70..7614533 100644 --- a/crates/voltex_editor/src/dock.rs +++ b/crates/voltex_editor/src/dock.rs @@ -1,8 +1,11 @@ const TAB_BAR_HEIGHT: f32 = 20.0; const MIN_RATIO: f32 = 0.1; const MAX_RATIO: f32 = 0.9; +#[allow(dead_code)] const RESIZE_HANDLE_HALF: f32 = 3.0; +#[allow(dead_code)] const GLYPH_W: f32 = 8.0; +#[allow(dead_code)] const TAB_PADDING: f32 = 8.0; #[derive(Clone, Copy, Debug)] @@ -52,6 +55,7 @@ pub struct LeafLayout { pub content_rect: Rect, } +#[allow(dead_code)] struct SplitLayout { rect: Rect, axis: Axis, @@ -59,6 +63,7 @@ struct SplitLayout { path: Vec, } +#[allow(dead_code)] struct ResizeState { path: Vec, axis: Axis, @@ -68,10 +73,13 @@ struct ResizeState { pub struct DockTree { root: DockNode, + #[allow(dead_code)] names: Vec<&'static str>, cached_leaves: Vec, cached_splits: Vec, + #[allow(dead_code)] resizing: Option, + #[allow(dead_code)] prev_mouse_down: bool, } @@ -85,13 +93,13 @@ fn layout_recursive( ) { match node { DockNode::Leaf { tabs, active } => { - debug_assert!(!tabs.is_empty(), "DockNode::Leaf must have at least one tab"); + assert!(!tabs.is_empty(), "DockNode::Leaf must have at least one tab"); let idx = *leaf_counter; *leaf_counter += 1; leaves.push(LeafLayout { leaf_index: idx, tabs: tabs.clone(), - active: (*active).min(tabs.len() - 1), + active: (*active).min(tabs.len().saturating_sub(1)), tab_bar_rect: Rect { x: rect.x, y: rect.y, w: rect.w, h: TAB_BAR_HEIGHT }, content_rect: Rect { x: rect.x,