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

Function cutCommand

src/cm/commandRegistry.js:1312–1337  ·  view source on GitHub ↗
(view)

Source from the content-addressed store, hash-verified

1310}
1311
1312function cutCommand(view) {
1313 const resolvedView = resolveView(view);
1314 if (!resolvedView) return false;
1315 const { state } = resolvedView;
1316 const ranges = state.selection.ranges;
1317 const segments = [];
1318 let changes = [];
1319 ranges.forEach((range) => {
1320 if (range.empty) {
1321 const line = state.doc.lineAt(range.head);
1322 segments.push(state.doc.sliceString(line.from, line.to));
1323 changes.push({ from: line.from, to: line.to, insert: "" });
1324 return;
1325 }
1326 segments.push(state.doc.sliceString(range.from, range.to));
1327 changes.push({ from: range.from, to: range.to, insert: "" });
1328 });
1329 cordova.plugins.clipboard.copy(segments.join("\n"));
1330 resolvedView.dispatch({
1331 changes,
1332 selection: EditorSelection.single(
1333 changes[0]?.from ?? state.selection.main.from,
1334 ),
1335 });
1336 return true;
1337}
1338
1339function pasteCommand(view) {
1340 const resolvedView = resolveView(view);

Callers

nothing calls this directly

Calls 2

resolveViewFunction · 0.85
copyMethod · 0.65

Tested by

no test coverage detected