Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add methods to track and restore key-table #130

Merged
merged 2 commits into from
Oct 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions src/fingers/commands/start.cr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ module Fingers::Commands

class Start < Cling::Command
@original_options : Hash(String, String) = {} of String => String
@last_pane_id : String | Nil
@last_key_table : String | Nil
@last_pane_id : String = "root"
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these two signatures are mixed up.

@mode : String = "default"
@pane_id : String = ""
@patterns : Array(String) = [] of String
Expand Down Expand Up @@ -56,6 +57,7 @@ module Fingers::Commands
end

track_options_to_restore
track_last_key_table
track_last_pane
show_hints

Expand Down Expand Up @@ -99,6 +101,15 @@ module Fingers::Commands
end
end

private def restore_last_key_table
tmux.set_key_table(@last_key_table)
end

private def track_last_key_table
last_key_table = tmux.exec("display-message -p '\#{client_key_table}'").chomp
@last_key_table = last_key_table unless last_key_table.empty?
end

private def restore_last_pane
tmux.select_pane(@last_pane_id)
tmux.select_pane(target_pane.pane_id)
Expand Down Expand Up @@ -145,12 +156,11 @@ module Fingers::Commands
end

private def teardown
tmux.set_key_table "root"

tmux.swap_panes(fingers_pane_id, target_pane.pane_id)
tmux.kill_pane(fingers_pane_id)

restore_last_pane
restore_last_key_table
restore_options

view.run_action if state.result
Expand Down