Fix height calculations using lipgloss.Height for accurate layout#62
Open
Fix height calculations using lipgloss.Height for accurate layout#62
Conversation
The footer height was double-counted in view.go: lipgloss.Render() already includes padding in the output string, but footerHeight added +2 again for padding. This caused the content area to be trimmed too aggressively. Additionally, model.go used a fixed constant (m.height - 7) for the task list height, which didn't account for footer text wrapping on small screens. Now both view.go and model.go measure actual rendered heights using lipgloss.Height, ensuring the task list gets the correct available space regardless of screen size or footer wrapping. https://claude.ai/code/session_01TRR9WnvruHoCMM4FKRXDfH
Two bugs in the scrolling logic: 1. Small screen mode hardcoded 2 lines per task (visibleHeight / 2), but each task actually renders 1 + len(narrowViewFields) lines. With the default 2 narrow fields (due, tags), tasks take 3 lines each. This caused the scroll to think more tasks fit than actually do, leaving the selected task outside the visible area. 2. Normal screen mode (updateScroll) completely ignored the scrollBuffer setting. It only ensured the cursor row was barely visible with no surrounding context. Now it calculates buffer zones in line-space above and below the cursor, keeping scrollBuffer tasks visible on each side. https://claude.ai/code/session_01TRR9WnvruHoCMM4FKRXDfH
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR improves the accuracy of component height calculations in the TUI by using
lipgloss.Height()instead of manual newline counting. This ensures proper handling of styled text with padding and accounts for footer text wrapping on small screens.Key Changes
model.go: Replaced hardcoded height calculation (7 lines) with dynamic measurement of actual rendered component heights
m.renderSections()andm.renderFooter()to measure their actual heightslipgloss.Height()to accurately account for padding and stylingview.go: Standardized height calculations to use
lipgloss.Height()consistentlystrings.Count(sectionsBar, "\n") + 1) withlipgloss.Height()lipgloss.Height()which already accounts for vertical paddingImplementation Details
lipgloss.Height()consistently across both files ensures the height calculations inmodel.goandview.goremain synchronizedhttps://claude.ai/code/session_01TRR9WnvruHoCMM4FKRXDfH