Skip to content

Commit 7fa08a9

Browse files
committed
fix: check current editor has focus
1 parent 45da50e commit 7fa08a9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

patches/clipboard.diff

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,18 +137,20 @@ Index: code-server/lib/vscode/src/vs/workbench/services/clipboard/browser/clipbo
137137
===================================================================
138138
--- code-server.orig/lib/vscode/src/vs/workbench/services/clipboard/browser/clipboardService.ts
139139
+++ code-server/lib/vscode/src/vs/workbench/services/clipboard/browser/clipboardService.ts
140-
@@ -15,19 +15,36 @@ import { IWorkbenchEnvironmentService }
140+
@@ -15,19 +15,38 @@ import { IWorkbenchEnvironmentService }
141141
import { ILogService } from '../../../../platform/log/common/log.js';
142142
import { ILayoutService } from '../../../../platform/layout/browser/layoutService.js';
143143
import { getActiveWindow } from '../../../../base/browser/dom.js';
144144
+import { isSafari } from '../../../../base/browser/browser.js';
145145
+import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
146+
+import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';
146147

147148
export class BrowserClipboardService extends BaseBrowserClipboardService {
148149

149150
constructor(
150151
@INotificationService private readonly notificationService: INotificationService,
151152
+ @IContextKeyService private readonly contextKeyService: IContextKeyService,
153+
+ @ICodeEditorService private readonly codeEditorService: ICodeEditorService,
152154
@IOpenerService private readonly openerService: IOpenerService,
153155
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
154156
@ILogService logService: ILogService,
@@ -158,7 +160,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/clipboard/browser/clipbo
158160
+ if (isSafari) {
159161
+ window.addEventListener('keydown', event => {
160162
+ if (
161-
+ (event.key.toLowerCase() === 'p' && this.contextKeyService.getContextKeyValue('vim.mode') === 'Normal') ||
163+
+ (event.key.toLowerCase() === 'p' && this.contextKeyService.getContextKeyValue('vim.mode') === 'Normal' && this.codeEditorService.getActiveCodeEditor()?.hasTextFocus()) ||
162164
+ (event.key === 'v' && (event.ctrlKey || event.metaKey) && this.contextKeyService.getContextKeyValue('vim.mode') === 'SearchInProgressMode')
163165
+ ) {
164166
+ this.lastClipboardTextContent = navigator.clipboard.readText()
@@ -174,7 +176,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/clipboard/browser/clipbo
174176
override async writeText(text: string, type?: string): Promise<void> {
175177
if (!!this.environmentService.extensionTestsLocationURI && typeof type !== 'string') {
176178
type = 'vscode-tests'; // force in-memory clipboard for tests to avoid permission issues
177-
@@ -46,6 +63,15 @@ export class BrowserClipboardService ext
179+
@@ -46,6 +65,15 @@ export class BrowserClipboardService ext
178180
}
179181

180182
try {

0 commit comments

Comments
 (0)