@@ -327,30 +327,62 @@ end
327
327
328
328
--- @param node Node
329
329
function 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 )
331
341
end
332
342
333
343
--- @param node Node
334
344
function 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 )
337
356
end
338
357
339
358
--- @param node Node
340
359
function 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
345
375
end
346
376
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
349
377
self :copy_to_reg (content )
350
378
end
351
379
352
380
--- @param node Node
353
381
function Clipboard :copy_absolute_path (node )
382
+ if node .name == " .." then
383
+ node = self .explorer
384
+ end
385
+
354
386
local absolute_path = node .absolute_path
355
387
local content = node .nodes ~= nil and utils .path_add_trailing (absolute_path ) or absolute_path
356
388
self :copy_to_reg (content )
0 commit comments