| 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(); |