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

Function getSelectedText

src/handlers/quickTools.js:801–820  ·  view source on GitHub ↗
(editor)

Source from the content-addressed store, hash-verified

799}
800
801function getSelectedText(editor) {
802 if (!editor) return "";
803 if (typeof editor.getSelectedText === "function") {
804 try {
805 return editor.getSelectedText() ?? "";
806 } catch (_) {
807 // fall back to CodeMirror state
808 }
809 }
810 try {
811 const { state } = editor;
812 if (!state) return "";
813 const { from, to } = state.selection.main ?? {};
814 if (typeof from !== "number" || typeof to !== "number") return "";
815 if (from === to) return "";
816 return state.sliceDoc(from, to);
817 } catch (_) {
818 return "";
819 }
820}
821
822function selectionMatchesQuery(editor, query) {
823 try {

Callers 1

toggleSearchFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected