@@ -327,30 +327,62 @@ end
327327
328328--- @param node Node
329329function Clipboard :copy_filename (node )
330- self :copy_to_reg (node .name )
330+ local content
331+
332+ if node .name == " .." then
333+ -- root
334+ content = vim .fn .fnamemodify (self .explorer .absolute_path , " :t" )
335+ else
336+ -- node
337+ content = node .name
338+ end
339+
340+ self :copy_to_reg (content )
331341end
332342
333343--- @param node Node
334344function Clipboard :copy_basename (node )
335- local basename = vim .fn .fnamemodify (node .name , " :r" )
336- self :copy_to_reg (basename )
345+ local content
346+
347+ if node .name == " .." then
348+ -- root
349+ content = vim .fn .fnamemodify (self .explorer .absolute_path , " :t:r" )
350+ else
351+ -- node
352+ content = vim .fn .fnamemodify (node .name , " :r" )
353+ end
354+
355+ self :copy_to_reg (content )
337356end
338357
339358--- @param node Node
340359function Clipboard :copy_path (node )
341- local absolute_path = node .absolute_path
342- local cwd = core .get_cwd ()
343- if cwd == nil then
344- return
360+ local content
361+
362+ if node .name == " .." then
363+ -- root
364+ content = utils .path_add_trailing " "
365+ else
366+ -- node
367+ local absolute_path = node .absolute_path
368+ local cwd = core .get_cwd ()
369+ if cwd == nil then
370+ return
371+ end
372+
373+ local relative_path = utils .path_relative (absolute_path , cwd )
374+ content = node .nodes ~= nil and utils .path_add_trailing (relative_path ) or relative_path
345375 end
346376
347- local relative_path = utils .path_relative (absolute_path , cwd )
348- local content = node .nodes ~= nil and utils .path_add_trailing (relative_path ) or relative_path
349377 self :copy_to_reg (content )
350378end
351379
352380--- @param node Node
353381function Clipboard :copy_absolute_path (node )
382+ if node .name == " .." then
383+ node = self .explorer
384+ end
385+
354386 local absolute_path = node .absolute_path
355387 local content = node .nodes ~= nil and utils .path_add_trailing (absolute_path ) or absolute_path
356388 self :copy_to_reg (content )
0 commit comments