Skip to content

Commit 83e928a

Browse files
Merge branch 'main' into highlight_error
2 parents 68a8ffe + 8ef979f commit 83e928a

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

python/mqt/debugger/dap/dap_server.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ def __init__(self, host: str = "127.0.0.1", port: int = 4711) -> None:
113113
self.port = port
114114
self.can_step_back = False
115115
self.simulation_state = mqt.debugger.SimulationState()
116+
self.source_file = {}
116117
self.lines_start_at_one = True
117118
self.columns_start_at_one = True
118119
self.pending_highlights: list[dict[str, Any]] = []
@@ -190,6 +191,10 @@ def handle_client(self, connection: socket.socket) -> None:
190191
e = mqt.debugger.dap.messages.InitializedDAPEvent()
191192
event_payload = json.dumps(e.encode())
192193
send_message(event_payload, connection)
194+
if isinstance(
195+
cmd, (mqt.debugger.dap.messages.LaunchDAPMessage, mqt.debugger.dap.messages.RestartDAPMessage)
196+
):
197+
self.reset_gray_out(connection)
193198
if (
194199
isinstance(
195200
cmd, (mqt.debugger.dap.messages.LaunchDAPMessage, mqt.debugger.dap.messages.RestartDAPMessage)
@@ -309,6 +314,14 @@ def handle_command(self, command: dict[str, Any]) -> tuple[dict[str, Any], mqt.d
309314
msg = f"Unsupported command: {command['command']}"
310315
raise RuntimeError(msg)
311316

317+
def reset_gray_out(self, connection: socket.socket) -> None:
318+
"""Reset all gray-out highlights in the client."""
319+
if not self.source_file:
320+
return
321+
e = mqt.debugger.dap.messages.GrayOutDAPEvent([], self.source_file)
322+
event_payload = json.dumps(e.encode())
323+
send_message(event_payload, connection)
324+
312325
def handle_assertion_fail(self, connection: socket.socket) -> None:
313326
"""Handles the sending of output events when an assertion fails.
314327

0 commit comments

Comments
 (0)