MCPcopy Create free account
hub / github.com/scriptscat/scriptcat / cutEditorSelection

Function cutEditorSelection

src/pages/options/routes/script/ScriptEditor.tsx:411–432  ·  view source on GitHub ↗
(editor: editor.ICodeEditor)

Source from the content-addressed store, hash-verified

409 });
410 };
411 const cutEditorSelection = (editor: editor.ICodeEditor) => {
412 const model = editor.getModel();
413 if (!model) return;
414 const selections = editor.getSelections()?.filter((selection) => !selection.isEmpty()) || [];
415 if (!selections.length) return;
416 const text = selections.map((selection) => model.getValueInRange(selection)).join(model.getEOL());
417 writeClipboardText(text)
418 .then(() => {
419 editor.pushUndoStop();
420 editor.executeEdits(
421 "menu",
422 selections.map((selection) => ({ range: selection, text: "" }))
423 );
424 editor.pushUndoStop();
425 })
426 .catch((err) => {
427 LoggerCore.logger(Logger.E(err)).debug("cut editor selection error");
428 })
429 .finally(() => {
430 editor.focus();
431 });
432 };
433 const pasteEditorClipboard = (editor: editor.ICodeEditor) => {
434 if (!navigator.clipboard?.readText) {
435 editor.focus();

Callers 1

actionFunction · 0.85

Calls 5

writeClipboardTextFunction · 0.85
debugMethod · 0.80
EMethod · 0.80
getModelMethod · 0.65
loggerMethod · 0.45

Tested by

no test coverage detected