Improve build system, stop debugger command on build, save on build

This commit is contained in:
Krzosa Karol
2023-01-30 11:42:04 +01:00
parent 1c2bf462ce
commit 2fece617b5

View File

@@ -153,6 +153,10 @@ class RemedyInstance:
if self.get_target_state() != TARGETSTATE_NONE: if self.get_target_state() != TARGETSTATE_NONE:
self.send_command(COMMAND_STOP_DEBUGGING) self.send_command(COMMAND_STOP_DEBUGGING)
def is_connected(self):
result = self.cmd_pipe != None
return result
def close(self): def close(self):
if self.cmd_pipe: if self.cmd_pipe:
win32file.CloseHandle(self.cmd_pipe) win32file.CloseHandle(self.cmd_pipe)
@@ -427,6 +431,8 @@ class RemedyBuildCommand(ExecCommand):
if remedy_instance.try_launching(): if remedy_instance.try_launching():
return return
self.window.run_command("save_all")
kwargs = { kwargs = {
"cmd": build.get("cmd", None), "cmd": build.get("cmd", None),
"shell_cmd": build.get("shell_cmd", None), "shell_cmd": build.get("shell_cmd", None),
@@ -455,14 +461,20 @@ class RemedyBuildCommand(ExecCommand):
super().run(**kwargs) super().run(**kwargs)
def on_finished(self, proc): def on_finished(self, proc):
super().on_finished(proc) super().on_finished(proc)
if self.command == "run_to_cursor":
remedy_instance.run_to_cursor() if proc == self.proc and proc.killed == False and proc.exit_code() == 0:
elif self.command == "start_debugging": errs = self.output_view.find_all_results()
remedy_instance.send_command(COMMAND_START_DEBUGGING) if len(errs) == 0:
elif self.command == "goto_cursor": if self.command == "run_to_cursor":
remedy_instance.goto_cursor() remedy_instance.run_to_cursor()
else: # @warning: While adding here also need to change error message !!!! elif self.command == "start_debugging":
sublime.message_dialog("RemedyBG: Unrecognized command =", self.command) remedy_instance.send_command(COMMAND_START_DEBUGGING)
elif self.command == "goto_cursor":
remedy_instance.goto_cursor()
else: # @warning: While adding here also need to change error message !!!!
sublime.message_dialog("RemedyBG: Unrecognized command =", self.command)
class RemedyLaunchCommand(sublime_plugin.WindowCommand): class RemedyLaunchCommand(sublime_plugin.WindowCommand):
def run(self): def run(self):
@@ -576,6 +588,8 @@ class RemedyAllInOneCommand(sublime_plugin.TextCommand):
class RemedyOnBuildCommand(sublime_plugin.EventListener): class RemedyOnBuildCommand(sublime_plugin.EventListener):
def on_window_command(self, window, command_name, args): def on_window_command(self, window, command_name, args):
if remedy_instance.is_connected() == False:
return
if command_name in ["build", "remedy_build"]: if command_name in ["build", "remedy_build"]:
if get_remedy_variable("stop_debugging_on_build_command", False): if get_remedy_variable("stop_debugging_on_build_command", False):
remedy_instance.stop_debugging() remedy_instance.stop_debugging()