Skip to content

Commit 8cc2098

Browse files
committed
Fixed issue in TUI where selection required an enter keypress, followed by one of S or C to connect via SFTP or SSH, respectively. New behavior is that if you are hovering over a node and press "c", it will select the node and then connect, so only one keypress is required.
1 parent 6a1d2c9 commit 8cc2098

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tui/tree.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from textual.app import App, ComposeResult
1616
from textual.containers import Container, VerticalScroll
1717
from textual.reactive import var
18-
from textual.widgets import DirectoryTree, Footer, Header, Static, Placeholder
18+
from textual.widgets import DirectoryTree, Footer, Header, Static, Placeholder, Tree
1919

2020
from configs import CONFIG_PATH as ROOT_CONFIG_PATH
2121
from tui.ssh_connections.ssh_connect import connect_shell, connect_sftp
@@ -110,20 +110,26 @@ def action_connect_ssh(self) -> None:
110110
Called in response to c key binding.
111111
:return:
112112
"""
113-
if not self.selected_file_path:
113+
path = self.query_one(Tree).cursor_node.data.path
114+
# Prevent selection of a group of nodes.
115+
if '.json' not in str(path).lower():
114116
pass
115117
else:
116-
self.return_command(connect_shell, config_path=self.selected_file_path)
118+
self.return_command(connect_shell, config_path=path)
117119

118120
def action_connect_sftp(self) -> None:
119121
"""
120122
Called in response to s key binding.
121123
:return:
122124
"""
123-
if not self.selected_file_path:
125+
path = self.query_one(Tree).cursor_node.data.path
126+
# Prevent selection of a group of nodes.
127+
if '.json' not in path.lower():
124128
pass
125129
else:
126-
self.return_command(connect_sftp, config_path=self.selected_file_path)
130+
self.return_command(connect_sftp, config_path=path)
131+
132+
127133

128134

129135
def main():

0 commit comments

Comments
 (0)