File tree Expand file tree Collapse file tree 6 files changed +22
-24
lines changed
Expand file tree Collapse file tree 6 files changed +22
-24
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ local find_file = require("nvim-tree.actions.finders.find-file").fn
99
1010local Class = require (" nvim-tree.classic" )
1111local DirectoryNode = require (" nvim-tree.node.directory" )
12+ local Node = require (" nvim-tree.node" )
1213
1314--- @alias ClipboardAction " copy" | " cut"
1415--- @alias ClipboardData table<ClipboardAction , Node[]>
178179--- Copy one or more nodes
179180--- @param node_or_nodes Node | Node[]
180181function Clipboard :copy (node_or_nodes )
181- if node_or_nodes .is then
182+ if type ( node_or_nodes ) == " table " and node_or_nodes .is and node_or_nodes : is ( Node ) then
182183 utils .array_remove (self .data .cut , node_or_nodes )
183184 toggle (node_or_nodes , self .data .copy )
184185 self .explorer .renderer :draw ()
190191--- Cut one or more nodes
191192--- @param node_or_nodes Node | Node[]
192193function Clipboard :cut (node_or_nodes )
193- if node_or_nodes .is then
194+ if type ( node_or_nodes ) == " table " and node_or_nodes .is and node_or_nodes : is ( Node ) then
194195 utils .array_remove (self .data .copy , node_or_nodes )
195196 toggle (node_or_nodes , self .data .cut )
196197 self .explorer .renderer :draw ()
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ local notify = require("nvim-tree.notify")
77
88local DirectoryLinkNode = require (" nvim-tree.node.directory-link" )
99local DirectoryNode = require (" nvim-tree.node.directory" )
10+ local Node = require (" nvim-tree.node" )
1011local RootNode = require (" nvim-tree.node.root" )
1112
1213local M = {
195196
196197--- @param node_or_nodes Node | Node[]
197198function M .fn (node_or_nodes )
198- if type (node_or_nodes ) == " table" and node_or_nodes .is then
199+ if type (node_or_nodes ) == " table" and node_or_nodes .is and node_or_nodes : is ( Node ) then
199200 remove_one (node_or_nodes )
200201 else
201202 remove_many (node_or_nodes )
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ local events = require("nvim-tree.events")
66
77local DirectoryLinkNode = require (" nvim-tree.node.directory-link" )
88local DirectoryNode = require (" nvim-tree.node.directory" )
9+ local Node = require (" nvim-tree.node" )
910local RootNode = require (" nvim-tree.node.root" )
1011
1112local M = {
144145
145146--- @param node_or_nodes Node | Node[]
146147function M .fn (node_or_nodes )
147- if type (node_or_nodes ) == " table" and node_or_nodes .is then
148+ if type (node_or_nodes ) == " table" and node_or_nodes .is and node_or_nodes : is ( Node ) then
148149 trash_one (node_or_nodes )
149150 else
150151 trash_many (node_or_nodes )
Original file line number Diff line number Diff line change @@ -124,6 +124,16 @@ local function compute(map)
124124
125125 table.sort (mappings , sort_fn )
126126
127+ -- sort mode characters for deterministic display e.g. "nx" not "xn"
128+ for _ , entry in ipairs (mappings ) do
129+ local chars = {}
130+ for c in entry .mode :gmatch (" ." ) do
131+ table.insert (chars , c )
132+ end
133+ table.sort (chars )
134+ entry .mode = table.concat (chars )
135+ end
136+
127137 -- longest lhs, mode and description
128138 local max_lhs = 0
129139 local max_mode = 0
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ local utils = require("nvim-tree.utils")
1010
1111local Class = require (" nvim-tree.classic" )
1212local DirectoryNode = require (" nvim-tree.node.directory" )
13+ local Node = require (" nvim-tree.node" )
1314
1415local function get_save_path (opts )
1516 if type (opts .bookmarks .persist ) == " string" then
117118--- @public
118119--- @param node_or_nodes Node | Node[]
119120function Marks :toggle (node_or_nodes )
120- if type (node_or_nodes ) == " table" and node_or_nodes .is then
121+ if type (node_or_nodes ) == " table" and node_or_nodes .is and node_or_nodes : is ( Node ) then
121122 self :toggle_one (node_or_nodes )
122123 else
123124 for _ , node in ipairs (node_or_nodes ) do
Original file line number Diff line number Diff line change 488488--- @param nodes Node[]
489489--- @return Node[]
490490function M .filter_descendant_nodes (nodes )
491- local dominated = {}
492- for i , a in ipairs (nodes ) do
493- for j , b in ipairs (nodes ) do
494- if i ~= j then
495- local prefix = b .absolute_path .. path_separator
496- if a .absolute_path :sub (1 , # prefix ) == prefix then
497- dominated [i ] = true
498- break
499- end
500- end
501- end
502- end
503- local filtered = {}
504- for i , node in ipairs (nodes ) do
505- if not dominated [i ] then
506- table.insert (filtered , node )
507- end
508- end
509- return filtered
491+ return vim .tbl_filter (function (node )
492+ return not vim .tbl_contains (nodes , node .parent )
493+ end , nodes )
510494end
511495
512496--- Build confirmation prompt strings based on default_yes config.
You can’t perform that action at this time.
0 commit comments