@@ -57,15 +57,16 @@ local os_sep = Path.path.sep
57
57
fb_actions .create = function (prompt_bufnr )
58
58
local current_picker = action_state .get_current_picker (prompt_bufnr )
59
59
local finder = current_picker .finder
60
- local file = fb_utils .get_valid_path (" Insert the file name: " , finder .path .. os_sep )
60
+ local quiet = finder .quiet
61
+ local file = fb_utils .get_valid_path (" Insert the file name: " , finder .path .. os_sep , { quiet = quiet })
61
62
if file then
62
63
if not fb_utils .is_dir (file .filename ) then
63
64
file :touch { parents = true }
64
65
else
65
66
Path :new (file .filename :sub (1 , - 2 )):mkdir { parents = true }
66
67
end
67
68
current_picker :refresh (finder , { reset_prompt = true , multi = current_picker ._multi })
68
- fb_utils .tele_notify (string.format (" \n %s created!" , file .filename ))
69
+ fb_utils .action_cmp_msg (string.format (" %s created!" , file .filename ), quiet )
69
70
end
70
71
end
71
72
@@ -152,6 +153,7 @@ fb_actions.rename = function(prompt_bufnr)
152
153
local current_picker = action_state .get_current_picker (prompt_bufnr )
153
154
local selections = fb_utils .get_selected_files (prompt_bufnr , false )
154
155
local parent_dir = Path :new (current_picker .finder .path ):parent ()
156
+ local quiet = current_picker .finder .quiet
155
157
156
158
if not vim .tbl_isempty (selections ) then
157
159
batch_rename (prompt_bufnr , selections )
@@ -168,7 +170,7 @@ fb_actions.rename = function(prompt_bufnr)
168
170
return
169
171
end
170
172
171
- local new_path = fb_utils .get_valid_path (" Insert a new name: " , old_path :absolute ())
173
+ local new_path = fb_utils .get_valid_path (" Insert a new name: " , old_path :absolute (), { quiet = quiet } )
172
174
if new_path then
173
175
-- rename changes old_name in place
174
176
local old_name = old_path :absolute ()
@@ -184,7 +186,7 @@ fb_actions.rename = function(prompt_bufnr)
184
186
current_picker ._multi :drop (entry )
185
187
end
186
188
current_picker :refresh (current_picker .finder )
187
- fb_utils .tele_notify (string.format (" \n %s renamed to %s!" , old_name , new_path .filename ))
189
+ fb_utils .action_cmp_msg (string.format (" %s renamed to %s!" , old_name , new_path .filename ), quiet )
188
190
end
189
191
end
190
192
end
@@ -215,7 +217,7 @@ fb_actions.move = function(prompt_bufnr)
215
217
file :rename {
216
218
new_name = new_path .filename ,
217
219
}
218
- fb_utils .tele_notify (string.format (" %s has been moved!" , filename ))
220
+ fb_utils .action_cmp_msg (string.format (" %s has been moved!" , filename ), finder . quiet , # selections )
219
221
end
220
222
end
221
223
229
231
fb_actions .copy = function (prompt_bufnr )
230
232
local current_picker = action_state .get_current_picker (prompt_bufnr )
231
233
local finder = current_picker .finder
234
+ local quiet = finder .quiet
232
235
if finder .files ~= nil and finder .files == false then
233
236
fb_utils .tele_notify (" Copying files in folder browser mode not supported." , log_levels .WARN )
234
237
return
@@ -252,15 +255,19 @@ fb_actions.copy = function(prompt_bufnr)
252
255
if file :parent ():absolute () == finder .path then
253
256
local absolute_path = file :absolute ()
254
257
fb_utils .tele_notify " Copying existing file or folder within original directory."
255
- destination = fb_utils .get_valid_path (" Please provide a new file or folder name: " , absolute_path )
258
+ destination = fb_utils .get_valid_path (
259
+ " Please provide a new file or folder name: " ,
260
+ absolute_path ,
261
+ { quiet = quiet }
262
+ )
256
263
end
257
264
if destination then
258
265
file :copy {
259
266
destination = destination ,
260
267
recursive = true ,
261
268
parents = true ,
262
269
}
263
- fb_utils .tele_notify (string.format (" %s has been copied!" , filename ))
270
+ fb_utils .action_cmp_msg (string.format (" %s has been copied!" , filename ), quiet , # selections )
264
271
end
265
272
end
266
273
272
279
--- @param prompt_bufnr number : The prompt bufnr
273
280
fb_actions .remove = function (prompt_bufnr )
274
281
local current_picker = action_state .get_current_picker (prompt_bufnr )
282
+ local quiet = current_picker .finder .quiet
275
283
local selections = fb_utils .get_selected_files (prompt_bufnr , true )
276
284
if vim .tbl_isempty (selections ) then
277
285
fb_utils .tele_notify " Nothing currently selected to be removed."
@@ -282,30 +290,27 @@ fb_actions.remove = function(prompt_bufnr)
282
290
return sel :absolute ()
283
291
end , selections )
284
292
285
- fb_utils .tele_notify " Following files/folders are going to be deleted:"
293
+ -- BUG: printing below completely messes with the y/n 'Operation aborted' & '.. has been removed!' printing
294
+ fb_utils .tele_notify " Following files/folders will be remove:"
286
295
for _ , file in ipairs (filenames ) do
287
296
fb_utils .tele_notify (" - " .. file )
288
297
end
289
298
290
- vim .ui .input ({ prompt = " [telescope] Remove selected files [y/N]: " }, function (input )
291
- if input and input :lower () == " y" then
292
- vim .notify " \n "
293
- for _ , p in ipairs (selections ) do
294
- local is_dir = p :is_dir ()
295
- p :rm { recursive = is_dir }
296
- -- clean up opened buffers
297
- if not is_dir then
298
- fb_utils .delete_buf (p :absolute ())
299
- else
300
- fb_utils .delete_dir_buf (p :absolute ())
301
- end
302
- fb_utils .tele_notify (string.format (" %s has been removed!" , p :absolute ()))
299
+ local ans = fb_utils .get_answer_yes (" Remove selected files" , false , { quiet = quiet })
300
+ if ans then
301
+ for _ , p in ipairs (selections ) do
302
+ local is_dir = p :is_dir ()
303
+ p :rm { recursive = is_dir }
304
+ -- clean up opened buffers
305
+ if not is_dir then
306
+ fb_utils .delete_buf (p :absolute ())
307
+ else
308
+ fb_utils .delete_dir_buf (p :absolute ())
303
309
end
304
- current_picker :refresh (current_picker .finder )
305
- else
306
- fb_utils .tele_notify " \n Removing files aborted!"
310
+ fb_utils .action_cmp_msg (string.format (" %s has been removed!" , p :absolute ()), quiet , # selections )
307
311
end
308
- end )
312
+ current_picker :refresh (current_picker .finder )
313
+ end
309
314
end
310
315
311
316
--- Toggle hidden files or folders for |fb_picker.file_browser|.
0 commit comments