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

Function get

src/lib/editorFile.js:78–227  ·  view source on GitHub ↗
(target, prop)

Source from the content-addressed store, hash-verified

76
77 return new Proxy(state, {
78 get(target, prop) {
79 if (prop === "__rawState") {
80 return target;
81 }
82
83 // Ace-compatible method: getValue()
84 if (prop === "getValue") {
85 return () => target.doc.toString();
86 }
87
88 // Ace-compatible method: setValue(text)
89 if (prop === "setValue") {
90 return (text) => {
91 const newText = String(text ?? "");
92 const { activeFile, editor } = editorManager;
93 if (activeFile?.id === file.id && editor) {
94 // Active file: dispatch to live EditorView
95 editor.dispatch({
96 changes: {
97 from: 0,
98 to: editor.state.doc.length,
99 insert: newText,
100 },
101 });
102 } else {
103 // Inactive file: update stored state
104 file._setRawSession(
105 target.update({
106 changes: { from: 0, to: target.doc.length, insert: newText },
107 }).state,
108 );
109 recordInactiveEdit();
110 }
111 };
112 }
113
114 // Ace-compatible method: getLine(row)
115 if (prop === "getLine") {
116 return (row) => {
117 try {
118 return target.doc.line(row + 1).text;
119 } catch (_) {
120 return "";
121 }
122 };
123 }
124
125 // Ace-compatible method: getLength()
126 if (prop === "getLength") {
127 return () => target.doc.lines;
128 }
129
130 // Ace-compatible method: getTextRange(range)
131 if (prop === "getTextRange") {
132 return (range) => {
133 if (!range) return "";
134 try {
135 const from = positionToOffset(range.start, target.doc);

Callers 1

editorFile.jsFile · 0.70

Calls 6

StringInterface · 0.85
recordInactiveEditFunction · 0.85
positionToOffsetFunction · 0.85
offsetToPositionFunction · 0.85
toStringMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected