File tree 3 files changed +21
-0
lines changed
3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -1527,6 +1527,13 @@ node.open.edit() *nvim-tree-api.node.open.edit()*
1527
1527
Folder: expand or collapse
1528
1528
Root: change directory up
1529
1529
1530
+ *nvim-tree-api.node.open.tab_drop()*
1531
+ node.open.tab_drop()
1532
+ Like edit(), but reuse already-opened window in tab. See also: | :drop |
1533
+ File: open already-opened as per | nvim-tree.actions.open_file |
1534
+ Folder: expand or collapse
1535
+ Root: change directory up
1536
+
1530
1537
*nvim-tree-api.node.open.replace_tree_buffer()*
1531
1538
node.open.replace_tree_buffer()
1532
1539
| nvim-tree-api.node.edit() | , file will be opened in place: in the
Original file line number Diff line number Diff line change @@ -141,13 +141,22 @@ local function pick_win_id()
141
141
return win_map [resp ]
142
142
end
143
143
144
+
144
145
local function open_file_in_tab (filename )
145
146
if M .quit_on_open then
146
147
view .close ()
147
148
end
148
149
vim .cmd (" tabe " .. vim .fn .fnameescape (filename ))
149
150
end
150
151
152
+ -- See :drop command. This will always focus already-opened tab
153
+ local function tab_drop (filename )
154
+ if M .quit_on_open then
155
+ view .close ()
156
+ end
157
+ vim .cmd (" tab :drop " .. vim .fn .fnameescape (filename ))
158
+ end
159
+
151
160
local function on_preview (buf_loaded )
152
161
if not buf_loaded then
153
162
vim .bo .bufhidden = " delete"
@@ -284,6 +293,10 @@ function M.fn(mode, filename)
284
293
return open_file_in_tab (filename )
285
294
end
286
295
296
+ if mode == " tab_drop" then
297
+ return tab_drop (filename )
298
+ end
299
+
287
300
if mode == " edit_in_place" then
288
301
return edit_in_current_buf (filename )
289
302
end
Original file line number Diff line number Diff line change @@ -162,6 +162,7 @@ local function open_preview(node)
162
162
end
163
163
164
164
Api .node .open .edit = wrap_node (open_or_expand_or_dir_up " edit" )
165
+ Api .node .open .tab_drop = wrap_node (open_or_expand_or_dir_up " tab_drop" )
165
166
Api .node .open .replace_tree_buffer = wrap_node (open_or_expand_or_dir_up " edit_in_place" )
166
167
Api .node .open .no_window_picker = wrap_node (open_or_expand_or_dir_up " edit_no_picker" )
167
168
Api .node .open .vertical = wrap_node (open_or_expand_or_dir_up " vsplit" )
You can’t perform that action at this time.
0 commit comments