MCPcopy
hub / github.com/witheve/Eve / formattingChange

Function formattingChange

src/ide.ts:624–645  ·  view source on GitHub ↗
(span:Span, change:Change, action?:FormatAction)

Source from the content-addressed store, hash-verified

622}
623
624function formattingChange(span:Span, change:Change, action?:FormatAction) {
625 let editor = span.editor;
626 let loc = span.find();
627 if(!loc) return;
628 // Cut the changed range out of a span
629 if(action == "split") {
630 let final = change.final;
631 editor.markSpan(loc.from, change.from, span.source);
632 // If the change is within the right edge of the span, recreate the remaining segment
633 if(comparePositions(final, loc.to) === -1) {
634 editor.markSpan(final, loc.to, span.source);
635 }
636 span.clear();
637
638 } else if(!action) {
639 // If we're at the end of the span, expand it to include the change
640 if(samePosition(loc.to, change.from)) {
641 span.clear();
642 editor.markSpan(loc.from, change.final, span.source);
643 }
644 }
645}
646
647function ctrlify(keymap) {
648 let finalKeymap = {};

Callers

nothing calls this directly

Calls 5

comparePositionsFunction · 0.90
samePositionFunction · 0.90
markSpanMethod · 0.80
findMethod · 0.65
clearMethod · 0.65

Tested by

no test coverage detected