mirror of
https://github.com/JanDeDobbeleer/oh-my-posh.git
synced 2025-02-21 02:55:37 -08:00
fix(cmd): do not evaluate execution time for an empty command
This commit is contained in:
parent
4b14195190
commit
8de89185e2
|
@ -20,8 +20,8 @@ end
|
||||||
|
|
||||||
-- Duration functions
|
-- Duration functions
|
||||||
|
|
||||||
local endedit_time
|
local endedit_time = 0
|
||||||
local last_duration
|
local last_duration = 0
|
||||||
local tip
|
local tip
|
||||||
local tooltip_active = false
|
local tooltip_active = false
|
||||||
local cached_prompt = {}
|
local cached_prompt = {}
|
||||||
|
@ -67,7 +67,7 @@ end
|
||||||
|
|
||||||
local function duration_onbeginedit()
|
local function duration_onbeginedit()
|
||||||
last_duration = 0
|
last_duration = 0
|
||||||
if endedit_time then
|
if endedit_time ~= 0 then
|
||||||
local beginedit_time = os_clock_millis()
|
local beginedit_time = os_clock_millis()
|
||||||
local elapsed = beginedit_time - endedit_time
|
local elapsed = beginedit_time - endedit_time
|
||||||
if elapsed >= 0 then
|
if elapsed >= 0 then
|
||||||
|
@ -76,8 +76,12 @@ local function duration_onbeginedit()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function duration_onendedit()
|
local function duration_onendedit(input)
|
||||||
endedit_time = os_clock_millis()
|
endedit_time = 0
|
||||||
|
-- For an empty command, the execution time should not be evaluated.
|
||||||
|
if string.gsub(input, "^%s*(.-)%s*$", "%1") ~= "" then
|
||||||
|
endedit_time = os_clock_millis()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Prompt functions
|
-- Prompt functions
|
||||||
|
@ -188,8 +192,8 @@ local function builtin_modules_onbeginedit()
|
||||||
duration_onbeginedit()
|
duration_onbeginedit()
|
||||||
end
|
end
|
||||||
|
|
||||||
local function builtin_modules_onendedit()
|
local function builtin_modules_onendedit(input)
|
||||||
duration_onendedit()
|
duration_onendedit(input)
|
||||||
end
|
end
|
||||||
|
|
||||||
if clink.onbeginedit ~= nil and clink.onendedit ~= nil then
|
if clink.onbeginedit ~= nil and clink.onendedit ~= nil then
|
||||||
|
|
Loading…
Reference in a new issue