tmux: Fix edge cases in paragraph text-object
Also add comments explaining the history & pane position checks in the C-y and C-e bindings, since I used those and had to rethink about what they're doing.
This commit is contained in:
@@ -176,11 +176,19 @@ bind -T copy-mode-vi i \
|
|||||||
}{ if -F "#{==:%1,p}" {
|
}{ if -F "#{==:%1,p}" {
|
||||||
# send "{j0o}k$"
|
# send "{j0o}k$"
|
||||||
send -X previous-paragraph
|
send -X previous-paragraph
|
||||||
send -X cursor-down
|
# don't move down if we're at the very first
|
||||||
|
# paragraph
|
||||||
|
if -F "#{||:#{e|<:#{scroll_position},#{history_size}},#{e|>:#{copy_cursor_y},#{scroll_region_upper}}}" {
|
||||||
|
send -X cursor-down
|
||||||
|
}
|
||||||
send -X start-of-line
|
send -X start-of-line
|
||||||
send -X other-end
|
send -X other-end
|
||||||
send -X next-paragraph
|
send -X next-paragraph
|
||||||
send -X cursor-up
|
# don't move up if we're at the very last
|
||||||
|
# paragraph
|
||||||
|
if -F "#{||:#{e|>:#{scroll_position},0},#{e|<:#{copy_cursor_y},#{scroll_region_lower}}}" {
|
||||||
|
send -X cursor-up
|
||||||
|
}
|
||||||
send -X end-of-line
|
send -X end-of-line
|
||||||
}{ if -F '#{==:%1,"}' {
|
}{ if -F '#{==:%1,"}' {
|
||||||
send -X jump-to-backward '"'
|
send -X jump-to-backward '"'
|
||||||
@@ -201,16 +209,20 @@ bind -T copy-mode-vi i \
|
|||||||
# scrolling when the respective line is visible. This mimics the behaviour of
|
# scrolling when the respective line is visible. This mimics the behaviour of
|
||||||
# vim's C-y at the top of the file.
|
# vim's C-y at the top of the file.
|
||||||
bind -T copy-mode-vi C-e \
|
bind -T copy-mode-vi C-e \
|
||||||
|
# check that there is still history beneath to scroll to.
|
||||||
if -F "#{e|>:#{scroll_position},0}" {
|
if -F "#{e|>:#{scroll_position},0}" {
|
||||||
send-keys -X scroll-down
|
send-keys -X scroll-down
|
||||||
|
# check that the cursor is not at the top of the pane
|
||||||
if -F "#{e|>:#{copy_cursor_y},#{scroll_region_upper}}" {
|
if -F "#{e|>:#{copy_cursor_y},#{scroll_region_upper}}" {
|
||||||
send-keys -X cursor-up
|
send-keys -X cursor-up
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bind -T copy-mode-vi C-y \
|
bind -T copy-mode-vi C-y \
|
||||||
|
# check that there is still history above to scroll to.
|
||||||
if -F "#{e|<:#{scroll_position},#{history_size}}" {
|
if -F "#{e|<:#{scroll_position},#{history_size}}" {
|
||||||
send-keys -X scroll-up
|
send-keys -X scroll-up
|
||||||
|
# check that the cursor is not at the bottom of the pane
|
||||||
if -F "#{e|<:#{copy_cursor_y},#{scroll_region_lower}}" {
|
if -F "#{e|<:#{copy_cursor_y},#{scroll_region_lower}}" {
|
||||||
send-keys -X cursor-down
|
send-keys -X cursor-down
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user