mirror of https://github.com/coder/code-server.git
Fix clipboard pasting
This commit is contained in:
parent
e61ea796c6
commit
2bc6e1a457
|
@ -175,7 +175,7 @@ index 1f8b17a..2a875f9 100644
|
||||||
+ await cli.main(args);
|
+ await cli.main(args);
|
||||||
+ return; // Always just do this for now.
|
+ return; // Always just do this for now.
|
||||||
diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts
|
diff --git a/src/vs/editor/browser/config/configuration.ts b/src/vs/editor/browser/config/configuration.ts
|
||||||
index f97a692..0206957 100644
|
index f97a692..8059a67 100644
|
||||||
--- a/src/vs/editor/browser/config/configuration.ts
|
--- a/src/vs/editor/browser/config/configuration.ts
|
||||||
+++ b/src/vs/editor/browser/config/configuration.ts
|
+++ b/src/vs/editor/browser/config/configuration.ts
|
||||||
@@ -10 +9,0 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
@@ -10 +9,0 @@ import { Disposable } from 'vs/base/common/lifecycle';
|
||||||
|
@ -187,9 +187,6 @@ index f97a692..0206957 100644
|
||||||
@@ -367 +366 @@ export class Configuration extends CommonEditorConfiguration {
|
@@ -367 +366 @@ export class Configuration extends CommonEditorConfiguration {
|
||||||
- if (platform.isMacintosh) {
|
- if (platform.isMacintosh) {
|
||||||
+ if (browser.isMacintosh) {
|
+ if (browser.isMacintosh) {
|
||||||
@@ -378 +377 @@ export class Configuration extends CommonEditorConfiguration {
|
|
||||||
- emptySelectionClipboard: browser.isWebKit || browser.isFirefox,
|
|
||||||
+ emptySelectionClipboard: false, // browser.isWebKit || browser.isFirefox,
|
|
||||||
diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts
|
diff --git a/src/vs/editor/browser/controller/mouseHandler.ts b/src/vs/editor/browser/controller/mouseHandler.ts
|
||||||
index b3b4472..f888d63 100644
|
index b3b4472..f888d63 100644
|
||||||
--- a/src/vs/editor/browser/controller/mouseHandler.ts
|
--- a/src/vs/editor/browser/controller/mouseHandler.ts
|
||||||
|
@ -250,33 +247,58 @@ index c69ea3f..b8d87f7 100644
|
||||||
-const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
|
-const GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
|
||||||
+const GOLDEN_LINE_HEIGHT_RATIO = browser.isMacintosh ? 1.5 : 1.35;
|
+const GOLDEN_LINE_HEIGHT_RATIO = browser.isMacintosh ? 1.5 : 1.35;
|
||||||
diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts
|
diff --git a/src/vs/editor/contrib/clipboard/clipboard.ts b/src/vs/editor/contrib/clipboard/clipboard.ts
|
||||||
index 990be3a..8a326c6 100644
|
index 990be3a..4bec789 100644
|
||||||
--- a/src/vs/editor/contrib/clipboard/clipboard.ts
|
--- a/src/vs/editor/contrib/clipboard/clipboard.ts
|
||||||
+++ b/src/vs/editor/contrib/clipboard/clipboard.ts
|
+++ b/src/vs/editor/contrib/clipboard/clipboard.ts
|
||||||
@@ -29 +29,2 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE)
|
@@ -18,0 +19 @@ import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegis
|
||||||
|
+import { clipboard } from 'electron';
|
||||||
|
@@ -29 +30,2 @@ const supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE)
|
||||||
-const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
|
-const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
|
||||||
+// const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
|
+// const supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
|
||||||
+const supportsPaste = true;
|
+const supportsPaste = true;
|
||||||
@@ -176,0 +178 @@ class ExecCommandPasteAction extends ExecCommandAction {
|
@@ -54,0 +57 @@ abstract class ExecCommandAction extends EditorAction {
|
||||||
|
+ console.log(document.activeElement!.cloneNode(true));
|
||||||
|
@@ -71 +74 @@ class ExecCommandCutAction extends ExecCommandAction {
|
||||||
|
- kbOpts = null;
|
||||||
|
+ // kbOpts = null;
|
||||||
|
@@ -119 +122 @@ class ExecCommandCopyAction extends ExecCommandAction {
|
||||||
|
- kbOpts = null;
|
||||||
|
+ // kbOpts = null;
|
||||||
|
@@ -174 +177 @@ class ExecCommandPasteAction extends ExecCommandAction {
|
||||||
|
- kbOpts = null;
|
||||||
|
+ // kbOpts = null;
|
||||||
|
@@ -176,0 +180 @@ class ExecCommandPasteAction extends ExecCommandAction {
|
||||||
+ const { workbench } = require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench');
|
+ const { workbench } = require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench');
|
||||||
@@ -181 +183 @@ class ExecCommandPasteAction extends ExecCommandAction {
|
@@ -181 +185 @@ class ExecCommandPasteAction extends ExecCommandAction {
|
||||||
- precondition: EditorContextKeys.writable,
|
- precondition: EditorContextKeys.writable,
|
||||||
+ precondition: (require('vs/platform/contextkey/common/contextkey') as typeof import('vs/platform/contextkey/common/contextkey')).ContextKeyExpr.and(EditorContextKeys.writable, workbench.clipboardContextKey),
|
+ precondition: (require('vs/platform/contextkey/common/contextkey') as typeof import('vs/platform/contextkey/common/contextkey')).ContextKeyExpr.and(EditorContextKeys.writable, workbench.clipboardContextKey),
|
||||||
@@ -191 +193,2 @@ class ExecCommandPasteAction extends ExecCommandAction {
|
@@ -191 +195,2 @@ class ExecCommandPasteAction extends ExecCommandAction {
|
||||||
- order: 3
|
- order: 3
|
||||||
+ order: 3,
|
+ order: 3,
|
||||||
+ when: workbench.clipboardContextKey,
|
+ when: workbench.clipboardContextKey,
|
||||||
@@ -194,0 +198,14 @@ class ExecCommandPasteAction extends ExecCommandAction {
|
@@ -194,0 +200,26 @@ class ExecCommandPasteAction extends ExecCommandAction {
|
||||||
+
|
+
|
||||||
+ public async run(accessor, editor: ICodeEditor): Promise<void> {
|
+ public async run(accessor, editor: ICodeEditor): Promise<void> {
|
||||||
+ if (editor instanceof (require('vs/editor/browser/widget/codeEditorWidget') as typeof import('vs/editor/browser/widget/codeEditorWidget')).CodeEditorWidget) {
|
+ if (editor instanceof (require('vs/editor/browser/widget/codeEditorWidget') as typeof import('vs/editor/browser/widget/codeEditorWidget')).CodeEditorWidget) {
|
||||||
+ try {
|
+ try {
|
||||||
|
+ editor.focus();
|
||||||
|
+ const textInput = document.activeElement! as HTMLTextAreaElement;
|
||||||
|
+ const dataTransfer = new DataTransfer();
|
||||||
|
+ const value = await clipboard.readText();
|
||||||
|
+ dataTransfer.setData("text/plain", value);
|
||||||
|
+ const pasteEvent = new ClipboardEvent("paste", {
|
||||||
|
+ clipboardData: dataTransfer,
|
||||||
|
+ });
|
||||||
|
+ textInput.dispatchEvent(pasteEvent);
|
||||||
|
+ } catch (ex) {
|
||||||
|
+ try {
|
||||||
+ editor.trigger('', (require('vs/editor/common/editorCommon') as typeof import ('vs/editor/common/editorCommon')).Handler.Paste, {
|
+ editor.trigger('', (require('vs/editor/common/editorCommon') as typeof import ('vs/editor/common/editorCommon')).Handler.Paste, {
|
||||||
+ text: await (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.clipboardText,
|
+ text: await (require('vs/../../../../packages/vscode/src/workbench') as typeof import ('vs/../../../../packages/vscode/src/workbench')).workbench.clipboardText,
|
||||||
+ });
|
+ });
|
||||||
+ } catch (ex) {
|
+ } catch (ex) {
|
||||||
+ super.run(accessor, editor);
|
+ super.run(accessor, editor);
|
||||||
+ }
|
+ }
|
||||||
|
+ }
|
||||||
+ } else {
|
+ } else {
|
||||||
+ super.run(accessor, editor);
|
+ super.run(accessor, editor);
|
||||||
+ }
|
+ }
|
||||||
|
|
Loading…
Reference in New Issue