Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix map clipboard #105

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 1 addition & 27 deletions src/tools.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as monaco from 'monaco-editor'
import { ContextKeyExpr, DisposableStore, KeybindingsRegistry } from 'vscode/monaco'
import { DisposableStore } from 'vscode/monaco'

interface PastePayload {
text: string
Expand Down Expand Up @@ -497,32 +497,6 @@ export function mapClipboard (
const disposableStore = new DisposableStore()
let copiedText = ''

disposableStore.add(
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'customCopy',
weight: 1000,
handler: () => {
copiedText = editor.getModel()!.getValueInRange(editor.getSelection()!)
document.execCommand('copy')
},
when: ContextKeyExpr.equals('editorId', editor.getId()),
primary: monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyC
})
)

disposableStore.add(
KeybindingsRegistry.registerCommandAndKeybindingRule({
id: 'customCut',
weight: 1000,
handler: () => {
copiedText = editor.getModel()!.getValueInRange(editor.getSelection()!)
document.execCommand('copy')
},
when: ContextKeyExpr.equals('editorId', editor.getId()),
primary: monaco.KeyMod.CtrlCmd | monaco.KeyCode.KeyX
})
)

const originalTrigger = editor.trigger
editor.trigger = function (source, handlerId, payload) {
if (handlerId === 'editor.action.clipboardCopyAction') {
Expand Down
Loading