diff --git a/vendor/clink.lua b/vendor/clink.lua index d022238..f63f3e9 100644 --- a/vendor/clink.lua +++ b/vendor/clink.lua @@ -338,7 +338,7 @@ end -- @return {false|svn branch name} --- local function get_svn_branch(svn_dir) - local file = io.popen("svn info 2>nul") + local file = io_popenyield("svn info 2>nul") for line in file:lines() do local m = line:match("^Relative URL:") if m then @@ -396,7 +396,7 @@ end -- @return {bool} --- local function get_svn_status() - local file = io.popen("svn status -q") + local file = io_popenyield("svn status -q") for line in file:lines() do file:close() return false @@ -573,12 +573,37 @@ local function svn_prompt_filter() nostatus = get_unknown_color() } - if get_svn_dir() then + local svn_dir = get_svn_dir() + if svn_dir then -- if we're inside of svn repo then try to detect current branch local branch = get_svn_branch() local color if branch then - if get_svn_status() then + -- If in a different repo or branch than last time, discard cached info + if cached_info.svn_dir ~= svn_dir or cached_info.svn_branch ~= branch then + cached_info.svn_info = nil + cached_info.svn_dir = svn_dir + cached_info.svn_branch = branch + end + -- Get the svn status using coroutine if available and option is enabled. Otherwise use a blocking call + local svnStatus + if clink.promptcoroutine and io.popenyield and settings.get("prompt.async") and prompt_overrideSvnStatusOptIn then + svnStatus = clink_promptcoroutine(function () + return get_svn_status() + end) + -- If the status result is pending, use the cached version instead, otherwise store it to the cache + if svnStatus == nil then + svnStatus = cached_info.svn_info + else + cached_info.svn_info = svnStatus + end + else + svnStatus = get_svn_status() + end + + if svnStatus == nil then + color = colors.nostatus + elseif svnStatus then color = colors.clean else color = colors.dirty @@ -589,7 +614,7 @@ local function svn_prompt_filter() end end - -- No mercurial present or not in mercurial file + -- No svn present or not in svn file clink.prompt.value = string.gsub(clink.prompt.value, "{svn}", "") return false end diff --git a/vendor/cmder_prompt_config.lua.default b/vendor/cmder_prompt_config.lua.default index 6847f25..b9fe15e 100644 --- a/vendor/cmder_prompt_config.lua.default +++ b/vendor/cmder_prompt_config.lua.default @@ -29,14 +29,19 @@ prompt_useUserAtHost = false -- default is false prompt_singleLine = false +-- OPTIONAL. If true then Cmder includes git, mercurial, and subversion status in the prompt. + -- default is true +prompt_includeVersionControl = true + -- OPTIONAL. If true then always ignore the cmder.status and cmder.cmdstatus git config settings and run the git prompt commands in the background. -- default is false -- NOTE: This only takes effect if using Clink v1.2.10 or higher. prompt_overrideGitStatusOptIn = false --- OPTIONAL. If true then Cmder includes git, mercurial, and subversion status in the prompt. - -- default is true -prompt_includeVersionControl = true +-- OPTIONAL. If true then always ignore the cmder.status and cmder.cmdstatus svn config settings and run the svn prompt commands in the background. + -- default is false + -- NOTE: This only takes effect if using Clink v1.2.10 or higher. +prompt_overrideSvnStatusOptIn = false -- Prompt Attributes --