@@ -13,7 +13,7 @@ local M = {
13
13
}
14
14
15
15
local clipboard = {
16
- move = {},
16
+ cut = {},
17
17
copy = {},
18
18
}
19
19
@@ -131,36 +131,36 @@ local function do_single_paste(source, dest, action_type, action_fn)
131
131
end
132
132
end
133
133
134
- local function add_to_clipboard (node , clip )
134
+ local function toggle (node , clip )
135
135
if node .name == " .." then
136
136
return
137
137
end
138
138
local notify_node = notify .render_path (node .absolute_path )
139
139
140
- for idx , _node in ipairs (clip ) do
141
- if _node .absolute_path == node .absolute_path then
142
- table.remove (clip , idx )
143
- return notify .info (notify_node .. " removed from clipboard." )
144
- end
140
+ if utils .array_remove (clip , node ) then
141
+ return notify .info (notify_node .. " removed from clipboard." )
145
142
end
143
+
146
144
table.insert (clip , node )
147
145
notify .info (notify_node .. " added to clipboard." )
148
146
end
149
147
150
148
function M .clear_clipboard ()
151
- clipboard .move = {}
149
+ clipboard .cut = {}
152
150
clipboard .copy = {}
153
151
notify .info " Clipboard has been emptied."
154
152
renderer .draw ()
155
153
end
156
154
157
155
function M .copy (node )
158
- add_to_clipboard (node , clipboard .copy )
156
+ utils .array_remove (clipboard .cut , node )
157
+ toggle (node , clipboard .copy )
159
158
renderer .draw ()
160
159
end
161
160
162
161
function M .cut (node )
163
- add_to_clipboard (node , clipboard .move )
162
+ utils .array_remove (clipboard .copy , node )
163
+ toggle (node , clipboard .cut )
164
164
renderer .draw ()
165
165
end
166
166
@@ -217,25 +217,25 @@ local function do_cut(source, destination)
217
217
end
218
218
219
219
function M .paste (node )
220
- if clipboard .move [1 ] ~= nil then
221
- return do_paste (node , " move " , do_cut )
220
+ if clipboard .cut [1 ] ~= nil then
221
+ return do_paste (node , " cut " , do_cut )
222
222
end
223
223
224
224
return do_paste (node , " copy" , do_copy )
225
225
end
226
226
227
227
function M .print_clipboard ()
228
228
local content = {}
229
- if # clipboard .move > 0 then
229
+ if # clipboard .cut > 0 then
230
230
table.insert (content , " Cut" )
231
- for _ , item in pairs (clipboard .move ) do
232
- table.insert (content , " * " .. (notify .render_path (item .absolute_path )))
231
+ for _ , node in pairs (clipboard .cut ) do
232
+ table.insert (content , " * " .. (notify .render_path (node .absolute_path )))
233
233
end
234
234
end
235
235
if # clipboard .copy > 0 then
236
236
table.insert (content , " Copy" )
237
- for _ , item in pairs (clipboard .copy ) do
238
- table.insert (content , " * " .. (notify .render_path (item .absolute_path )))
237
+ for _ , node in pairs (clipboard .copy ) do
238
+ table.insert (content , " * " .. (notify .render_path (node .absolute_path )))
239
239
end
240
240
end
241
241
275
275
--- @param node table
276
276
--- @return string | nil group
277
277
function M .get_highlight (node )
278
- for _ , n in ipairs (clipboard .move ) do
278
+ for _ , n in ipairs (clipboard .cut ) do
279
279
if node == n then
280
280
return " NvimTreeCutText"
281
281
end
0 commit comments