Skip to content

Commit f237ba6

Browse files
committed
update log
1 parent c6b164b commit f237ba6

File tree

4 files changed

+18
-52
lines changed

4 files changed

+18
-52
lines changed

lua/neo-tree/log.lua

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ log_maker.new = function(config)
100100
or table.concat({ config.plugin_short, prefix }, " ")
101101

102102
local title_opts = { title = config.plugin_short }
103+
103104
---@param message string
104105
---@param level vim.log.levels
105106
local notify = vim.schedule_wrap(function(message, level)
@@ -205,9 +206,7 @@ log_maker.new = function(config)
205206

206207
-- Output to console
207208
if config.use_console and can_log_to_console then
208-
vim.schedule(function()
209-
notify(msg, log_level)
210-
end)
209+
notify(msg, log_level)
211210
end
212211
end
213212
end
@@ -262,6 +261,9 @@ log_maker.new = function(config)
262261
log.error = logfunc(Levels.ERROR, make_string)
263262
---Unused, kept around for compatibility at the moment. Remove in v4.0.
264263
log.fatal = logfunc(Levels.FATAL, make_string)
264+
265+
log.notify = notify
266+
log.levels = Levels
265267
-- tree-sitter queries recognize any .format and highlight it w/ string.format highlights
266268
---@type table<string, { format: fun(fmt: string?, ...: any) }>
267269
log.at = {
@@ -374,8 +376,11 @@ log_maker.new = function(config)
374376
else
375377
errmsg = "assertion failed!"
376378
end
379+
local old = config.use_console
380+
config.use_console = false
377381
log.error(errmsg)
378-
return assert(v, errmsg)
382+
config.use_console = old
383+
error(errmsg, 2)
379384
end
380385

381386
---@param context string

lua/neo-tree/sources/filesystem/lib/fs_actions.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ M.trash_node = function(path, callback, noconfirm)
717717
return
718718
end
719719

720-
trash.trash({ path })
720+
log.assert(trash.trash({ path }))
721721
log.info("Trashed", path)
722722
complete()
723723
end

lua/neo-tree/trash.lua

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ end
8484

8585
---@param paths string[]
8686
---@return boolean success
87+
---@return string? err
8788
M.trash = function(paths)
8889
local cmds = M.generate_commands(paths)
8990
for _, command in ipairs(cmds) do
@@ -99,12 +100,11 @@ M.trash = function(paths)
99100
}, paths)
100101
log.debug("Running trash command", full_command)
101102
local trash_ok, output = utils.execute_command(full_command)
102-
if trash_ok then
103-
log.debug("Trashed", paths, "using", table.concat(command, " "))
104-
else
105-
log.error("Could not trash with", full_command, ":", output)
103+
if not trash_ok then
104+
return false, "Could not trash with " .. full_command .. ":" .. output
106105
end
107-
return trash_ok
106+
log.debug("Trashed", paths, "using", full_command)
107+
return true
108108
end
109109

110110
if type(command) == "function" then
@@ -117,15 +117,14 @@ M.trash = function(paths)
117117
-- assume it's already executable
118118
local trash_ok = utils.execute_command(cmd)
119119
if not trash_ok then
120-
log.error("Error executing trash command", cmd, ", aborting operation.")
121-
return false
120+
return false,
121+
"Error executing trash command " .. table.concat(cmd, " ") .. ", aborting operation."
122122
end
123123
end
124124
return true
125125
end
126126

127-
log.error("Invalid trash command:", command)
128-
return false
127+
return false, "Invalid trash command:" .. command
129128
until true
130129
end
131130
return false

release.sh

Lines changed: 0 additions & 38 deletions
This file was deleted.

0 commit comments

Comments
 (0)