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