Skip to content

Commit 2bc6e1a

Browse files
committed
Fix clipboard pasting
1 parent e61ea79 commit 2bc6e1a

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

scripts/vscode.patch

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ index 1f8b17a..2a875f9 100644
175175
+ await cli.main(args);
176176
+ return; // Always just do this for now.
177177
diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts
178-
index f97a692..0206957 100644
178+
index f97a692..8059a67 100644
179179
--- a/src/vs/editor/browser/config/configuration.ts
180180
+++ b/src/vs/editor/browser/config/configuration.ts
181181
@@ -10 +9,0 @@ import { Disposable } from 'vs/base/common/lifecycle';
@@ -187,9 +187,6 @@ index f97a692..0206957 100644
187187
@@ -367 +366 @@ export class Configuration extends CommonEditorConfiguration {
188188
- if (platform.isMacintosh) {
189189
+ if (browser.isMacintosh) {
190-
@@ -378 +377 @@ export class Configuration extends CommonEditorConfiguration {
191-
- emptySelectionClipboard: browser.isWebKit || browser.isFirefox,
192-
+ emptySelectionClipboard: false, // browser.isWebKit || browser.isFirefox,
193190
diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts
194191
index b3b4472..f888d63 100644
195192
--- a/src/vs/editor/browser/controller/mouseHandler.ts
@@ -250,32 +247,57 @@ index c69ea3f..b8d87f7 100644
250247
-const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
251248
+const GOLDEN_LINE_HEIGHT_RATIO = browser.isMacintosh ? 1.5 : 1.35;
252249
diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts
253-
index 990be3a..8a326c6 100644
250+
index 990be3a..4bec789 100644
254251
--- a/src/vs/editor/contrib/clipboard/clipboard.ts
255252
+++ b/src/vs/editor/contrib/clipboard/clipboard.ts
256-
@@ -29 +29,2 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE)
253+
@@ -18,0 +19 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
254+
+import { clipboard } from 'electron';
255+
@@ -29 +30,2 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE)
257256
-const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
258257
+// const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
259258
+const supportsPaste = true;
260-
@@ -176,0 +178 @@ class ExecCommandPasteAction extends ExecCommandAction {
259+
@@ -54,0 +57 @@ abstract class ExecCommandAction extends EditorAction {
260+
+ console.log(document.activeElement!.cloneNode(true));
261+
@@ -71 +74 @@ class ExecCommandCutAction extends ExecCommandAction {
262+
- kbOpts = null;
263+
+ // kbOpts = null;
264+
@@ -119 +122 @@ class ExecCommandCopyAction extends ExecCommandAction {
265+
- kbOpts = null;
266+
+ // kbOpts = null;
267+
@@ -174 +177 @@ class ExecCommandPasteAction extends ExecCommandAction {
268+
- kbOpts = null;
269+
+ // kbOpts = null;
270+
@@ -176,0 +180 @@ class ExecCommandPasteAction extends ExecCommandAction {
261271
+ const { workbench } = require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench');
262-
@@ -181 +183 @@ class ExecCommandPasteAction extends ExecCommandAction {
272+
@@ -181 +185 @@ class ExecCommandPasteAction extends ExecCommandAction {
263273
- precondition: EditorContextKeys.writable,
264274
+ precondition: (require('vs/platform/contextkey/common/contextkey') as typeof import('vs/platform/contextkey/common/contextkey')).ContextKeyExpr.and(EditorContextKeys.writable, workbench.clipboardContextKey),
265-
@@ -191 +193,2 @@ class ExecCommandPasteAction extends ExecCommandAction {
275+
@@ -191 +195,2 @@ class ExecCommandPasteAction extends ExecCommandAction {
266276
- order: 3
267277
+ order: 3,
268278
+ when: workbench.clipboardContextKey,
269-
@@ -194,0 +198,14 @@ class ExecCommandPasteAction extends ExecCommandAction {
279+
@@ -194,0 +200,26 @@ class ExecCommandPasteAction extends ExecCommandAction {
270280
+
271281
+ public async run(accessor, editor: ICodeEditor): Promise<void> {
272282
+ if (editor instanceof (require('vs/editor/browser/widget/codeEditorWidget') as typeof import('vs/editor/browser/widget/codeEditorWidget')).CodeEditorWidget) {
273283
+ try {
274-
+ editor.trigger('', (require('vs/editor/common/editorCommon') as typeof import ('vs/editor/common/editorCommon')).Handler.Paste, {
275-
+ text: await (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.clipboardText,
284+
+ editor.focus();
285+
+ const textInput = document.activeElement! as HTMLTextAreaElement;
286+
+ const dataTransfer = new DataTransfer();
287+
+ const value = await clipboard.readText();
288+
+ dataTransfer.setData("text/plain", value);
289+
+ const pasteEvent = new ClipboardEvent("paste", {
290+
+ clipboardData: dataTransfer,
276291
+ });
292+
+ textInput.dispatchEvent(pasteEvent);
277293
+ } catch (ex) {
278-
+ super.run(accessor, editor);
294+
+ try {
295+
+ editor.trigger('', (require('vs/editor/common/editorCommon') as typeof import ('vs/editor/common/editorCommon')).Handler.Paste, {
296+
+ text: await (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.clipboardText,
297+
+ });
298+
+ } catch (ex) {
299+
+ super.run(accessor, editor);
300+
+ }
279301
+ }
280302
+ } else {
281303
+ super.run(accessor, editor);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy