Skip to content

Commit 199f02b

Browse files
Changing toggle behavior to move the tree if needed
1 parent d70ec00 commit 199f02b

2 files changed

Lines changed: 10 additions & 3 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ any of the operations/commands, bind to the labeled API in the table below.
9595

9696
| Command | Keybinding(s) | What it does | API for `bindings.json` |
9797
| :------- | :------------------------- | :------------------------------------------------------------------------------------------ | :------------------------------------ |
98-
| `tree` | - | Open/close the tree | `filemanager2.toggle_tree` |
98+
| `tree` | - | Open/close the tree, or moves to the tree to current tab if opened in different tab | `filemanager2.toggle_tree` |
9999
| - | <kbd>Tab</kbd> & MouseLeft | Open a file, or go into the directory. Goes back a dir if on `..` | `filemanager2.try_open_at_cursor` |
100100
| - | <kbd>→</kbd> | Expand directory in tree listing | `filemanager2.uncompress_at_cursor` |
101101
| - | <kbd>←</kbd> | Collapse directory listing | `filemanager2.compress_at_cursor` |

filemanager2.lua

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,11 +1044,18 @@ local function close_tree()
10441044
end
10451045

10461046
-- toggle_tree will toggle the tree view visible (create) and hide (delete).
1047-
function toggle_tree()
1047+
function toggle_tree(bp)
10481048
if tree_view == nil then
10491049
open_tree()
10501050
else
1051-
close_tree()
1051+
-- If the file tree share the same tab, close the tree,
1052+
-- otherwise just move the tree to current tab
1053+
if bp:Tab() == tree_view:Tab() then
1054+
close_tree()
1055+
else
1056+
close_tree()
1057+
open_tree()
1058+
end
10521059
end
10531060
end
10541061

0 commit comments

Comments
 (0)