Skip to content

Commit 0b9fac9

Browse files
authored
fix: the manually stoped/restarted job show the error message (nvim-java#242) (nvim-java#243)
1 parent 36b2d8d commit 0b9fac9

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lua/java/api/runner.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function M.built_in.stop_app()
3838
async(function()
3939
M.runner:stop_run()
4040
end)
41-
.catch(get_error_handler('Failed to switch run'))
41+
.catch(get_error_handler('Failed to stop run'))
4242
.run()
4343
end
4444

lua/java/runner/run.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ local notify = require('java-core.utils.notify')
66
---@field main_class string
77
---@field buffer number
88
---@field is_running boolean
9+
---@field is_manually_stoped boolean
910
---@field private cmd string
1011
---@field private term_chan_id number
1112
---@field private job_chan_id number | nil
@@ -46,6 +47,7 @@ function Run:stop()
4647
return
4748
end
4849

50+
self.is_manually_stoped = true
4951
vim.fn.jobstop(self.job_chan_id)
5052
vim.fn.jobwait({ self.job_chan_id }, 1000)
5153
self.job_chan_id = nil
@@ -77,8 +79,9 @@ function Run:on_job_exit(exit_code)
7779

7880
self.is_running = false
7981

80-
if exit_code == 0 then
82+
if exit_code == 0 or self.is_manually_stoped then
8183
self.is_failure = false
84+
self.is_manually_stoped = false
8285
else
8386
self.is_failure = true
8487
notify.error(string.format('%s %s', self.name, message))

0 commit comments

Comments
 (0)