MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / getCurrentSelectionLineRange

Function getCurrentSelectionLineRange

src/cm/lineNumberSelection.ts:43–60  ·  view source on GitHub ↗
(state: EditorView["state"])

Source from the content-addressed store, hash-verified

41}
42
43function getCurrentSelectionLineRange(state: EditorView["state"]): {
44 from: number;
45 to: number;
46} {
47 const selection = state.selection.main;
48 const startLine = state.doc.lineAt(selection.from);
49 const endPos = selection.empty
50 ? selection.head
51 : Math.max(selection.to - 1, selection.from);
52 const endLine = state.doc.lineAt(endPos);
53 const startRange = getLineSelectionRange(state, startLine);
54 const endRange = getLineSelectionRange(state, endLine);
55
56 return {
57 from: startRange?.from ?? selection.from,
58 to: endRange?.to ?? selection.to,
59 };
60}
61
62function createLineSelection(range: {
63 from: number;

Callers 1

Calls 1

getLineSelectionRangeFunction · 0.85

Tested by

no test coverage detected