MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / getEdits

Method getEdits

src/actions/CopyLines.ts:42–65  ·  view source on GitHub ↗
(
    editor: TextEditor,
    ranges: { range: Range; isParagraph: boolean }[]
  )

Source from the content-addressed store, hash-verified

40 }
41
42 private getEdits(
43 editor: TextEditor,
44 ranges: { range: Range; isParagraph: boolean }[]
45 ) {
46 return ranges.map(({ range, isParagraph }) => {
47 const delimiter = isParagraph ? "\n\n" : "\n";
48 let text = editor.document.getText(range);
49 const length = text.length;
50 text = this.isUp ? `${delimiter}${text}` : `${text}${delimiter}`;
51 const newRange = this.isUp
52 ? new Range(range.end, range.end)
53 : new Range(range.start, range.start);
54 return {
55 edit: {
56 editor,
57 range: newRange,
58 text,
59 isReplace: this.isUp,
60 },
61 offset: delimiter.length,
62 length,
63 };
64 });
65 }
66
67 async run([targets]: [TypedSelection[]]): Promise<ActionReturnValue> {
68 const results = flatten(

Callers 1

runMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected