Skip to content

Commit f2f7c22

Browse files
authored
Merge pull request #90 from gaoconggit/codex-clear-all-breakpoints
feat: 增加一键清空所有断点功能,便于快速重置调试状态
2 parents 2c2d38a + 8a49ecd commit f2f7c22

3 files changed

Lines changed: 60 additions & 4 deletions

File tree

SharpPad/wwwroot/editor/editor.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ Provide only the code to insert at the cursor position.`
151151
this.setupDebuggerBreakpoints();
152152
this.setupDebuggerBreakpointToggle();
153153
this.setupDebuggerBreakpointHover();
154+
this.setupClearBreakpointsButton();
154155

155156
return this.editor;
156157
}
@@ -519,9 +520,38 @@ Provide only the code to insert at the cursor position.`
519520
this.breakpointTooltip = tooltip;
520521
return tooltip;
521522
}
522-
523-
defineVSDarkTheme() {
524-
monaco.editor.defineTheme('vs-dark-custom', {
523+
524+
setupClearBreakpointsButton() {
525+
const clearBreakpointsButton = document.getElementById('clearBreakpointsButton');
526+
if (!clearBreakpointsButton) {
527+
return;
528+
}
529+
530+
clearBreakpointsButton.addEventListener('click', () => {
531+
this.clearAllBreakpoints();
532+
});
533+
}
534+
535+
clearAllBreakpoints() {
536+
this.setBreakpointLines([]);
537+
538+
try {
539+
const keysToRemove = [];
540+
for (let index = 0; index < localStorage.length; index += 1) {
541+
const key = localStorage.key(index);
542+
if (key && key.startsWith(this.breakpointStoragePrefix)) {
543+
keysToRemove.push(key);
544+
}
545+
}
546+
547+
keysToRemove.forEach(key => localStorage.removeItem(key));
548+
} catch (error) {
549+
console.warn('无法清空全部断点信息:', error);
550+
}
551+
}
552+
553+
defineVSDarkTheme() {
554+
monaco.editor.defineTheme('vs-dark-custom', {
525555
base: 'vs-dark',
526556
inherit: true,
527557
rules: [

SharpPad/wwwroot/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@
8383
<button id="runButton" title="运行 (Ctrl+Enter)">运行</button>
8484
<button id="stopButton" title="停止运行" style="display: none;">停止</button>
8585
<button id="buildExeButton" title="生成发布包">发布</button>
86+
<button id="clearBreakpointsButton" title="删除所有断点">清断点</button>
8687
<div style="flex-grow: 0.1;"></div>
8788
</div>
8889
</div>

SharpPad/wwwroot/styles/base.css

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ body.theme-light .chat-messages .assistant-message {
313313
font-size: 13px !important;
314314
}
315315

316-
#runButton, #buildExeButton {
316+
#runButton, #buildExeButton, #clearBreakpointsButton {
317317
padding: 4px 10px !important;
318318
font-size: 13px !important;
319319
margin-right: 6px !important;
@@ -389,6 +389,31 @@ body.theme-light #systemSettingsBtn:active {
389389
margin-right: 2.5rem;
390390
}
391391

392+
#clearBreakpointsButton {
393+
padding: 5px 12px;
394+
border: none;
395+
border-radius: 4px;
396+
background-color: #6c757d;
397+
color: white;
398+
cursor: pointer;
399+
font-size: 14px;
400+
transition: background-color 0.2s;
401+
margin-right: 2rem;
402+
}
403+
404+
#clearBreakpointsButton:hover {
405+
background-color: #5a6268;
406+
}
407+
408+
body.theme-light #clearBreakpointsButton {
409+
background-color: #d0d4d9;
410+
color: #333333;
411+
}
412+
413+
body.theme-light #clearBreakpointsButton:hover {
414+
background-color: #c0c4c9;
415+
}
416+
392417
#buildExeButton:hover {
393418
background-color: #218838;
394419
}

0 commit comments

Comments
 (0)