tenseleyflow/fackr / 32adda5

Browse files

fix last line cursor visual mismatch

Authored by espadonne
SHA
32adda571a39c159534627efed176f17f42681ee
Parents
7d2548c
Tree
2ad2850

3 changed files

StatusFile+-
M src/editor/state.rs 6 5
M src/render/screen.rs 11 1
M src/workspace/state.rs 3 2
src/editor/state.rsmodified
@@ -1638,7 +1638,8 @@ impl Editor {
16381638
         } else {
16391639
             0
16401640
         };
1641
-        let top_offset = if self.workspace.tabs.len() > 1 { 1 } else { 0 };
1641
+        // Tab bar is always rendered (takes 1 row)
1642
+        let top_offset = 1;
16421643
 
16431644
         // Calculate line number column width (same as in screen.rs)
16441645
         let line_num_width = {
@@ -1766,8 +1767,8 @@ impl Editor {
17661767
             }
17671768
             Mouse::ScrollDown { .. } => {
17681769
                 // Scroll down 3 lines
1769
-                // Calculate visible rows (accounting for tab bar, gap, and status bar)
1770
-                let top_offset = if self.workspace.tabs.len() > 1 { 1 } else { 0 };
1770
+                // Calculate visible rows (tab bar always rendered, plus gap and status bar)
1771
+                let top_offset = 1;
17711772
                 let visible_rows = (self.screen.rows as usize).saturating_sub(2 + top_offset);
17721773
                 // Max viewport is when the last line is at the bottom of visible area
17731774
                 let max_viewport = self.buffer().line_count().saturating_sub(visible_rows).max(0);
@@ -4448,8 +4449,8 @@ impl Editor {
44484449
     // === Viewport ===
44494450
 
44504451
     fn scroll_to_cursor(&mut self) {
4451
-        // Calculate top offset (tab bar takes 1 row if multiple tabs)
4452
-        let top_offset = if self.workspace.tabs.len() > 1 { 1 } else { 0 };
4452
+        // Tab bar is always rendered (takes 1 row)
4453
+        let top_offset = 1;
44534454
         // Vertical scrolling (2 rows reserved: gap + status bar, plus top_offset for tab bar)
44544455
         let visible_rows = (self.screen.rows as usize).saturating_sub(2 + top_offset);
44554456
 
src/render/screen.rsmodified
@@ -285,7 +285,7 @@ impl Screen {
285285
 
286286
         // Calculate available screen area
287287
         let available_width = self.cols.saturating_sub(left_offset) as f32;
288
-        let available_height = self.rows.saturating_sub(1 + top_offset) as f32; // -1 for status bar
288
+        let available_height = self.rows.saturating_sub(2 + top_offset) as f32; // -2 for gap + status bar
289289
 
290290
         // Track where to place the hardware cursor (active pane's primary cursor)
291291
         let mut cursor_screen_pos: Option<(u16, u16)> = None;
@@ -342,6 +342,16 @@ impl Screen {
342342
             }
343343
         }
344344
 
345
+        // Render the gap row (empty line between text and status bar)
346
+        let gap_row = top_offset + available_height as u16;
347
+        execute!(
348
+            self.stdout,
349
+            MoveTo(left_offset, gap_row),
350
+            SetBackgroundColor(BG_COLOR),
351
+            Clear(ClearType::UntilNewLine),
352
+            ResetColor
353
+        )?;
354
+
345355
         // Render status bar (use active pane's info)
346356
         if let Some(active_pane) = panes.iter().find(|p| p.is_active) {
347357
             self.render_status_bar_with_offset(
src/workspace/state.rsmodified
@@ -599,7 +599,7 @@ impl Tab {
599599
     pub fn pane_at_screen_position(&self, col: u16, row: u16, screen_cols: u16, screen_rows: u16, left_offset: u16, top_offset: u16) -> usize {
600600
         // Available space for panes (excluding fuss width and tab bar)
601601
         let available_width = screen_cols.saturating_sub(left_offset) as f32;
602
-        let available_height = screen_rows.saturating_sub(1 + top_offset) as f32; // -1 for status bar
602
+        let available_height = screen_rows.saturating_sub(2 + top_offset) as f32; // -2 for gap + status bar
603603
 
604604
         // Adjust click coordinates for offsets
605605
         let adj_col = col.saturating_sub(left_offset) as f32;
@@ -1423,7 +1423,8 @@ impl Workspace {
14231423
         } else {
14241424
             0
14251425
         };
1426
-        let top_offset = if self.tabs.len() > 1 { 1u16 } else { 0 };
1426
+        // Tab bar is always rendered (takes 1 row)
1427
+        let top_offset = 1u16;
14271428
 
14281429
         self.tabs[self.active_tab].pane_at_screen_position(
14291430
             col, row, screen_cols, screen_rows, fuss_width, top_offset