🚀 Clear assertion greyed-out lines on restart and highlight issue locations#232
🚀 Clear assertion greyed-out lines on restart and highlight issue locations#232svenjeschmitt-ops wants to merge 169 commits intomunich-quantum-toolkit:mainfrom
Conversation
e73b5b7 to
3ab0733
Compare
src/backend/dd/DDSimDebug.cpp
Outdated
| ddsim->qc = std::make_unique<qc::QuantumComputation>(imported); | ||
| qc::CircuitOptimizer::flattenOperations(*ddsim->qc, true); | ||
| } catch (const ParsingError& e) { | ||
| ddsim->lastLoadErrorDetail = e.detail(); |
There was a problem hiding this comment.
Surely we don't need this member variable anymore, right? e.detail() is only used in this function, we might as well make it a local variable.
There was a problem hiding this comment.
We still need the member. LoadResult.message is a const char*, and we return ddsim->lastLoadErrorDetail.c_str(). That pointer must stay valid after ddsimLoadCode returns. If we make it a local std::string, the pointer will dangle as soon as the function exits. To remove the member, we’d need to change the API to return an owning string or copy into caller-owned storage.
There was a problem hiding this comment.
@svenjeschmitt-ops you resolved this comment, but I think it still isn't addressed, right? The member variable is still in there.
There was a problem hiding this comment.
Yes, the member variable is still there intentionally. We can’t safely make it local because LoadResult.message is a const char* that must remain valid after ddsimLoadCode returns, and we return ddsim->lastLoadErrorDetail.c_str(). If we want to remove the member, we’d need to change the API to return an owning string or require caller-provided storage.
There was a problem hiding this comment.
Gotcha, but then it would be cleaner to have the LoadResult own the string rather than use a pointer I think...
| auto* ddsim = toDDSimulationState(self); | ||
| if (!ddsim->ready) { | ||
| return ERROR; | ||
| } |
There was a problem hiding this comment.
Sorry to bother you on this, but I'd actually appreciate a response here 😅
a179094 to
7ea1084
Compare
fdfd0c8 to
0606738
Compare
DRovara
left a comment
There was a problem hiding this comment.
Hi @svenjeschmitt-ops, here's the latest review.
There's just 2 remaining points: the open discussion and the unneeded member variable. It would be cool if we could fix that soon so that the PR can be merged before it deviates too much from the main branch.
| auto* ddsim = toDDSimulationState(self); | ||
| if (!ddsim->ready) { | ||
| return ERROR; | ||
| } |
There was a problem hiding this comment.
Just in case you responded: I still cannot see any response from you here. Please make sure that no orange "Pending" symbol is shown next to your comments.
Description
This pull request improves the debugging highlight functionality and fixes an issue where greyed-out highlights were not correctly reset between executions.
When an issue is detected in the code, the extension highlights the affected line in red and displays a descriptive error message explaining the nature of the problem. This visual feedback helps users quickly identify both the location of the error and its underlying cause.
A second part of the implementation concerns the assertion functionality. After an assertion failure, the extension greys out all lines of code that cannot have caused the error. While this behaviour is intended, the greyed-out highlights were previously not cleared when a new execution started. As a result, lines remained greyed out until the editor was closed and reopened.
Overall, the highlighting functionality provides an efficient way to show where an error occurred and what caused it. This change introduces an explicit reset of all greyed-out highlights on launch and restart events, ensuring that each execution starts with a clean editor state.
Fixes #(issue)
Checklist: