Skip to content

Commit 4404dc6

Browse files
authored
Explorer: cannot copy paste anymore to duplicate file with sandbox enabled (fix microsoft#154820) (microsoft#155044)
* Explorer: cannot copy paste anymore to duplicate file with sandbox enabled (fix microsoft#154820) * skip smudge!
1 parent 5737c7e commit 4404dc6

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

src/vs/base/parts/sandbox/electron-browser/preload.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@
145145
/**
146146
* @param {string} channel
147147
* @param {any[]} args
148-
* @returns {Promise<any> | undefined}
148+
* @returns {Promise<any> | never}
149149
*/
150150
invoke(channel, ...args) {
151151
if (validateIPC(channel)) {
@@ -156,7 +156,7 @@
156156
/**
157157
* @param {string} channel
158158
* @param {(event: IpcRendererEvent, ...args: any[]) => void} listener
159-
* @returns {IpcRenderer}
159+
* @returns {IpcRenderer | never}
160160
*/
161161
on(channel, listener) {
162162
if (validateIPC(channel)) {
@@ -169,7 +169,7 @@
169169
/**
170170
* @param {string} channel
171171
* @param {(event: IpcRendererEvent, ...args: any[]) => void} listener
172-
* @returns {IpcRenderer}
172+
* @returns {IpcRenderer | never}
173173
*/
174174
once(channel, listener) {
175175
if (validateIPC(channel)) {
@@ -182,7 +182,7 @@
182182
/**
183183
* @param {string} channel
184184
* @param {(event: IpcRendererEvent, ...args: any[]) => void} listener
185-
* @returns {IpcRenderer}
185+
* @returns {IpcRenderer | never}
186186
*/
187187
removeListener(channel, listener) {
188188
if (validateIPC(channel)) {

src/vs/platform/native/common/native.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6+
import { VSBuffer } from 'vs/base/common/buffer';
67
import { Event } from 'vs/base/common/event';
78
import { URI } from 'vs/base/common/uri';
89
import { MessageBoxOptions, MessageBoxReturnValue, MouseInputEvent, OpenDevToolsOptions, OpenDialogOptions, OpenDialogReturnValue, SaveDialogOptions, SaveDialogReturnValue } from 'vs/base/parts/sandbox/common/electronTypes';
@@ -121,8 +122,8 @@ export interface ICommonNativeHostService {
121122
writeClipboardText(text: string, type?: 'selection' | 'clipboard'): Promise<void>;
122123
readClipboardFindText(): Promise<string>;
123124
writeClipboardFindText(text: string): Promise<void>;
124-
writeClipboardBuffer(format: string, buffer: Uint8Array, type?: 'selection' | 'clipboard'): Promise<void>;
125-
readClipboardBuffer(format: string): Promise<Uint8Array>;
125+
writeClipboardBuffer(format: string, buffer: VSBuffer, type?: 'selection' | 'clipboard'): Promise<void>;
126+
readClipboardBuffer(format: string): Promise<VSBuffer>;
126127
hasClipboard(format: string, type?: 'selection' | 'clipboard'): Promise<boolean>;
127128

128129
// macOS Touchbar

src/vs/platform/native/electron-main/nativeHostMainService.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import { IColorScheme, IOpenedWindow, IOpenEmptyWindowOptions, IOpenWindowOption
3939
import { IWindowsMainService, OpenContext } from 'vs/platform/windows/electron-main/windows';
4040
import { isWorkspaceIdentifier } from 'vs/platform/workspace/common/workspace';
4141
import { IWorkspacesManagementMainService } from 'vs/platform/workspaces/electron-main/workspacesManagementMainService';
42+
import { VSBuffer } from 'vs/base/common/buffer';
4243

4344
export interface INativeHostMainService extends AddFirstParameterToFunctions<ICommonNativeHostService, Promise<unknown> /* only methods, not events */, number | undefined /* window ID */> { }
4445

@@ -603,12 +604,12 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
603604
return clipboard.writeFindText(text);
604605
}
605606

606-
async writeClipboardBuffer(windowId: number | undefined, format: string, buffer: Uint8Array, type?: 'selection' | 'clipboard'): Promise<void> {
607-
return clipboard.writeBuffer(format, Buffer.from(buffer), type);
607+
async writeClipboardBuffer(windowId: number | undefined, format: string, buffer: VSBuffer, type?: 'selection' | 'clipboard'): Promise<void> {
608+
return clipboard.writeBuffer(format, Buffer.from(buffer.buffer), type);
608609
}
609610

610-
async readClipboardBuffer(windowId: number | undefined, format: string): Promise<Uint8Array> {
611-
return clipboard.readBuffer(format);
611+
async readClipboardBuffer(windowId: number | undefined, format: string): Promise<VSBuffer> {
612+
return VSBuffer.wrap(clipboard.readBuffer(format));
612613
}
613614

614615
async hasClipboard(windowId: number | undefined, format: string, type?: 'selection' | 'clipboard'): Promise<boolean> {

src/vs/workbench/services/clipboard/electron-sandbox/clipboardService.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ export class NativeClipboardService implements IClipboardService {
5656
return this.nativeHostService.hasClipboard(NativeClipboardService.FILE_FORMAT);
5757
}
5858

59-
private resourcesToBuffer(resources: URI[]): Uint8Array {
60-
return VSBuffer.fromString(resources.map(r => r.toString()).join('\n')).buffer;
59+
private resourcesToBuffer(resources: URI[]): VSBuffer {
60+
return VSBuffer.fromString(resources.map(r => r.toString()).join('\n'));
6161
}
6262

63-
private bufferToResources(buffer: Uint8Array): URI[] {
63+
private bufferToResources(buffer: VSBuffer): URI[] {
6464
if (!buffer) {
6565
return [];
6666
}

src/vs/workbench/test/electron-browser/workbenchTestServices.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ import { joinPath } from 'vs/base/common/resources';
5454
import { UserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfileService';
5555
import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/common/userDataProfile';
5656
import { UriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentityService';
57+
import { VSBuffer } from 'vs/base/common/buffer';
5758

5859
const args = parseArgs(process.argv, OPTIONS);
5960

@@ -272,8 +273,8 @@ export class TestNativeHostService implements INativeHostService {
272273
async writeClipboardText(text: string, type?: 'selection' | 'clipboard' | undefined): Promise<void> { }
273274
async readClipboardFindText(): Promise<string> { return ''; }
274275
async writeClipboardFindText(text: string): Promise<void> { }
275-
async writeClipboardBuffer(format: string, buffer: Uint8Array, type?: 'selection' | 'clipboard' | undefined): Promise<void> { }
276-
async readClipboardBuffer(format: string): Promise<Uint8Array> { return Uint8Array.from([]); }
276+
async writeClipboardBuffer(format: string, buffer: VSBuffer, type?: 'selection' | 'clipboard' | undefined): Promise<void> { }
277+
async readClipboardBuffer(format: string): Promise<VSBuffer> { return VSBuffer.wrap(Uint8Array.from([])); }
277278
async hasClipboard(format: string, type?: 'selection' | 'clipboard' | undefined): Promise<boolean> { return false; }
278279
async sendInputEvent(event: MouseInputEvent): Promise<void> { }
279280
async windowsGetStringRegKey(hive: 'HKEY_CURRENT_USER' | 'HKEY_LOCAL_MACHINE' | 'HKEY_CLASSES_ROOT' | 'HKEY_USERS' | 'HKEY_CURRENT_CONFIG', path: string, name: string): Promise<string | undefined> { return undefined; }

0 commit comments

Comments
 (0)