Fix broken thumbs rendering & race condition #151
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.
Bug fix
There are several bugs that this PR addresses:
long line bug
This PR fixes the issue by calculating the row position based on the terminal's column size. Inspired by #139.
wrong position of hint
Multibyte character handling was incorrect, so as a starship user thumbs always printed abnormaly.
(mentioned by #76)
This PR attempts a new way to insert the hint in the appropriate position, which renders each line just once.
So it works well on all the samples including
samples/test1
.As in the comment, it tries to find the position of the hint inside the line:
race-condition in tmux-thumbs
There's a race condition between new-window command and swap-pane command. (also mentioned by #69 )
This is because the executor returns as soon as the new window is created and does not block until the whole command in the parameter
tmux capture-pane ~~
is executed.Assume the active pane is small. There is an issue for each of the execution flow:
swap-pane
-capture-pane
and `thumbs: Active pane is captured in the bigger pane (created by new-window), so more lines including the lines that were not visible in the small pane are captured. This causes rendering issues on thumbs.capture-pane
andthumbs
-swap-pane
: thumbs screen is rendered on the bigger pane, and then moved to the smaller pane, which causes long lines to be trimmed.This PR tries to enforce the execution flow of the former, by inserting
sleep
beforecapture-pane
(although this isn't strict. please tell me a better idea)The issue mentioned is fixed by the new render function.
Issue with this PR
If osc52 is enabled, tmux enters search mode with blank screen after thumbs selection, so you must press enter one more time. I have no idea why this issue occurs, but it has to do something with the new rendering function.
I should mention that I'm new to rust (literally my first writing in rust), so if there's any quirk in the style please let me know. Thanks.