From e13ac90672c2822304efffbf23b72c33716a57f6 Mon Sep 17 00:00:00 2001 From: Asman Umbetov Date: Wed, 6 Mar 2024 10:07:31 +0300 Subject: [PATCH 1/2] fix(#2395): marks.bulk.move defaults to directory at cursor --- lua/nvim-tree/marks/bulk-move.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/nvim-tree/marks/bulk-move.lua b/lua/nvim-tree/marks/bulk-move.lua index 33351c419f3..285f190ccaf 100644 --- a/lua/nvim-tree/marks/bulk-move.lua +++ b/lua/nvim-tree/marks/bulk-move.lua @@ -3,6 +3,7 @@ local core = require "nvim-tree.core" local utils = require "nvim-tree.utils" local rename_file = require "nvim-tree.actions.fs.rename-file" local notify = require "nvim-tree.notify" +local lib = require "nvim-tree.lib" local M = { config = {}, @@ -14,9 +15,18 @@ function M.bulk_move() return end + local node_at_cursor = lib.get_node_at_cursor() + local default_path = core.get_cwd() + + if node_at_cursor and node_at_cursor.type ~= "directory" then + default_path = node_at_cursor.parent.absolute_path + elseif node_at_cursor then + default_path = node_at_cursor.absolute_path + end + local input_opts = { prompt = "Move to: ", - default = core.get_cwd(), + default = default_path, completion = "dir", } From 0fc503283701747d3bb4db46f7ee4c117db03fc3 Mon Sep 17 00:00:00 2001 From: Asman Umbetov Date: Thu, 14 Mar 2024 13:31:13 +0300 Subject: [PATCH 2/2] fix(#2395): adds check if node_at_cursor.parent is nil --- lua/nvim-tree/marks/bulk-move.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lua/nvim-tree/marks/bulk-move.lua b/lua/nvim-tree/marks/bulk-move.lua index 285f190ccaf..9e6e9a9d653 100644 --- a/lua/nvim-tree/marks/bulk-move.lua +++ b/lua/nvim-tree/marks/bulk-move.lua @@ -18,10 +18,10 @@ function M.bulk_move() local node_at_cursor = lib.get_node_at_cursor() local default_path = core.get_cwd() - if node_at_cursor and node_at_cursor.type ~= "directory" then - default_path = node_at_cursor.parent.absolute_path - elseif node_at_cursor then + if node_at_cursor and node_at_cursor.type == "directory" then default_path = node_at_cursor.absolute_path + elseif node_at_cursor and node_at_cursor.parent then + default_path = node_at_cursor.parent.absolute_path end local input_opts = {