Skip to content

Commit 87877e7

Browse files
committed
only enable this feature when vim mode is active
1 parent 6eb0362 commit 87877e7

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

patches/clipboard.diff

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,21 +137,30 @@ 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,6 +15,7 @@ import { IWorkbenchEnvironmentService }
140+
@@ -15,19 +15,36 @@ 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';
145+
+import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
145146

146147
export class BrowserClipboardService extends BaseBrowserClipboardService {
147148

148-
@@ -26,8 +27,19 @@ export class BrowserClipboardService ext
149+
constructor(
150+
@INotificationService private readonly notificationService: INotificationService,
151+
+ @IContextKeyService private readonly contextKeyService: IContextKeyService,
152+
@IOpenerService private readonly openerService: IOpenerService,
153+
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
154+
@ILogService logService: ILogService,
149155
@ILayoutService layoutService: ILayoutService
150156
) {
151157
super(layoutService, logService);
152158
+ if (isSafari) {
153159
+ window.addEventListener('keydown', event => {
154-
+ if (event.key.toLowerCase() === 'p' || (event.key === 'v' && (event.ctrlKey || event.metaKey))) {
160+
+ if (
161+
+ (event.key.toLowerCase() === 'p' && this.contextKeyService.getContextKeyValue('vim.mode') === 'Normal') ||
162+
+ (event.key === 'v' && (event.ctrlKey || event.metaKey) && this.contextKeyService.getContextKeyValue('vim.mode') === 'SearchInProgressMode')
163+
+ ) {
155164
+ this.lastClipboardTextContent = navigator.clipboard.readText()
156165
+ this.lastCLipboardTime = Date.now();
157166
+ }
@@ -165,7 +174,7 @@ Index: code-server/lib/vscode/src/vs/workbench/services/clipboard/browser/clipbo
165174
override async writeText(text: string, type?: string): Promise<void> {
166175
if (!!this.environmentService.extensionTestsLocationURI && typeof type !== 'string') {
167176
type = 'vscode-tests'; // force in-memory clipboard for tests to avoid permission issues
168-
@@ -46,6 +58,15 @@ export class BrowserClipboardService ext
177+
@@ -46,6 +63,15 @@ export class BrowserClipboardService ext
169178
}
170179

171180
try {

0 commit comments

Comments
 (0)