Skip to content

Commit 5290897

Browse files
committed
chore: resolve undefined-field
1 parent eacb610 commit 5290897

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lua/nvim-tree/actions/fs/clipboard.lua

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,11 @@ end
221221
function Clipboard:do_paste(node, action, action_fn)
222222
if node.name == ".." then
223223
node = self.explorer
224-
elseif node:is(DirectoryNode) then
225-
node = node:last_group_node()
224+
else
225+
local dir = node:as(DirectoryNode)
226+
if dir then
227+
node = dir:last_group_node()
228+
end
226229
end
227230
local clip = self.data[action]
228231
if #clip == 0 then
@@ -373,7 +376,7 @@ function Clipboard:copy_path(node)
373376
end
374377

375378
local relative_path = utils.path_relative(absolute_path, cwd)
376-
content = node.nodes ~= nil and utils.path_add_trailing(relative_path) or relative_path
379+
content = node:is(DirectoryNode) and utils.path_add_trailing(relative_path) or relative_path
377380
end
378381

379382
self:copy_to_reg(content)

0 commit comments

Comments
 (0)