fix(filepicker): remove loop iteration appending extra newline#914
Open
bntrtm wants to merge 1 commit intocharmbracelet:mainfrom
Open
fix(filepicker): remove loop iteration appending extra newline#914bntrtm wants to merge 1 commit intocharmbracelet:mainfrom
bntrtm wants to merge 1 commit intocharmbracelet:mainfrom
Conversation
This was referenced Mar 23, 2026
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.
The Issue
The lines in question are implemented for the purposes of filling out empty terminal space. At least, that's my read on it. However, by adding a loop iteration for where the height of the filepicker string equals the height of the terminal itself, we end up adding an extra newline we don't need.
Example
Context first. Assume that the filepicker model's internal
heightvariable is4, our terminal height set withSetHeight. Keep in mind thatlipgloss.Heightreturnsnum \n chars + 1to calculate the cell height. Assume thats, by the time the loop begins, isa_file\nb_file\nc_file.With condition being
i <= m.Height():With condition being
i < m.Height():When simply using the filepicker model in and of itself, we don't really see the consequence of the unexpected behavior. But we do begin to see it as soon as we want to nest it within other models, as seen in the case of the
gum filemodel.If desired, this branch in my fork of
gumdemonstrates what this fix looks like in v1.0.0 (the same logic applies in this v2 PR;gumsimply uses v1 charm versions), alongside a (only somewhat unrelated) gum fix. If you clone it and change the conditional operator underfilepicker.View()from<back to<=, you'll find that the command to rungum fileunexpectedly remains rendered on the first line of the TUI, without this fix.Related Issues
I personally have a theory that a lack of clarification on
lipgloss.Height's in-line documentation is what led to this conditional bug.If this fix is merged, I would reason that an identical fix is necessary in v1 for
gum's sake. If a maintainer is willing to open a v1 maintenance branch, I can submit an identical PR for that; I have a branch already made for that purpose.