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

Function loadFolds

src/cm/editorUtils.ts:131–150  ·  view source on GitHub ↗
(
		state: EditorState,
		saved: FoldSpan[],
	)

Source from the content-addressed store, hash-verified

129 }
130
131 function loadFolds(
132 state: EditorState,
133 saved: FoldSpan[],
134 ): StateEffect<{ from: number; to: number }>[] {
135 const doc = state.doc;
136 const effects: StateEffect<{ from: number; to: number }>[] = [];
137
138 for (const f of saved) {
139 // Validate line numbers
140 if (f.fromLine < 1 || f.fromLine > doc.lines) continue;
141 if (f.toLine < 1 || f.toLine > doc.lines) continue;
142
143 const from = lineColToOffset(doc, f.fromLine, f.fromCol);
144 const to = lineColToOffset(doc, f.toLine, f.toCol);
145 if (to > from) {
146 effects.push(foldEffect.of({ from, to }));
147 }
148 }
149 return effects;
150 }
151
152 const restoreEffects = loadFolds(view.state, folds);
153 if (restoreEffects.length) {

Callers 1

restoreFoldsFunction · 0.85

Calls 1

lineColToOffsetFunction · 0.85

Tested by

no test coverage detected