Skip to content

Commit 88f7c83

Browse files
committed
feat(diagnostics): make diagnostic messages selectable and copyable
- Refactor diagnostic rendering to use DOM elements (`span.diagnostic`) instead of CSS `::after` pseudo-elements - Add `DiagnosticRenderer` to manage diagnostic message lifecycle - Update `Selection` and `Mouse` logic to ignore diagnostic elements during code navigation and cursor placement - Implement `isInsideDiagnostic` and `getLineTextLength` helpers to correctly handle mixed content lines - Allow native text selection and copying for diagnostics by bypassing default editor events when interacting with them - Prevent diagnostic selection interference when selecting code via `.code.selecting` CSS state - Update backend ignore defaults to include `target` and `node_modules`
1 parent 4af8285 commit 88f7c83

11 files changed

Lines changed: 306 additions & 190 deletions

File tree

anycode-backend/src/utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ pub const DEFAULT_IGNORE_DIRS: &[&str] = &[
77
".git",
88
// Python
99
"__pycache__", ".pytest_cache",
10+
11+
"target", "node_modules",
1012
];
1113

1214
pub const DEFAULT_IGNORE_FILES: &[&str] = &[

anycode-base/src/cursor.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AnycodeLine } from './utils';
1+
import { AnycodeLine, isDiagnosticElement } from './utils';
22

33
export function removeCursor() {
44
const sel = window.getSelection();
@@ -18,7 +18,10 @@ export function moveCursor(
1818

1919
var character: number = column;
2020

21-
const chunks = Array.from(lineDiv.children).map(l => l as AnycodeLine);
21+
const chunks = Array.from(lineDiv.children)
22+
.filter((child) => !isDiagnosticElement(child))
23+
.map(l => l as AnycodeLine);
24+
2225
let chunkCharacter = 0;
2326
let chunk: Element | null = null;
2427

0 commit comments

Comments
 (0)