mirror of https://github.com/microsoft/vscode.git
Calling webContents.paste on the floating window (#246106)
* calling paste on the right floating window * adding back new lines
This commit is contained in:
parent
3d39bdf93f
commit
6916ae0d31
|
@ -4,7 +4,7 @@
|
|||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as browser from '../../../../base/browser/browser.js';
|
||||
import { getActiveDocument } from '../../../../base/browser/dom.js';
|
||||
import { getActiveDocument, getActiveWindow } from '../../../../base/browser/dom.js';
|
||||
import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';
|
||||
import * as platform from '../../../../base/common/platform.js';
|
||||
import { StopWatch } from '../../../../base/common/stopwatch.js';
|
||||
|
@ -248,7 +248,7 @@ if (PasteAction) {
|
|||
}
|
||||
|
||||
const sw = StopWatch.create(true);
|
||||
const triggerPaste = clipboardService.triggerPaste();
|
||||
const triggerPaste = clipboardService.triggerPaste(getActiveWindow().vscodeWindowId);
|
||||
if (triggerPaste) {
|
||||
return triggerPaste.then(async () => {
|
||||
|
||||
|
@ -301,7 +301,7 @@ if (PasteAction) {
|
|||
|
||||
// 2. Paste: (default) handle case when focus is somewhere else.
|
||||
PasteAction.addImplementation(0, 'generic-dom', (accessor: ServicesAccessor, args: any) => {
|
||||
const triggerPaste = accessor.get(IClipboardService).triggerPaste();
|
||||
const triggerPaste = accessor.get(IClipboardService).triggerPaste(getActiveWindow().vscodeWindowId);
|
||||
return triggerPaste ?? false;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@ export interface IClipboardService {
|
|||
/**
|
||||
* Trigger the paste. Returns undefined if the paste was not triggered or a promise that resolves on paste end.
|
||||
*/
|
||||
triggerPaste(): Promise<void> | undefined;
|
||||
triggerPaste(targetWindowId: number): Promise<void> | undefined;
|
||||
|
||||
/**
|
||||
* Writes text to the system clipboard.
|
||||
|
|
|
@ -150,7 +150,7 @@ export interface ICommonNativeHostService {
|
|||
killProcess(pid: number, code: string): Promise<void>;
|
||||
|
||||
// Clipboard
|
||||
triggerPaste(): Promise<void>;
|
||||
triggerPaste(options?: INativeHostOptions): Promise<void>;
|
||||
readClipboardText(type?: 'selection' | 'clipboard'): Promise<string>;
|
||||
writeClipboardText(text: string, type?: 'selection' | 'clipboard'): Promise<void>;
|
||||
readClipboardFindText(): Promise<string>;
|
||||
|
|
|
@ -751,8 +751,8 @@ export class NativeHostMainService extends Disposable implements INativeHostMain
|
|||
return clipboard.readText(type);
|
||||
}
|
||||
|
||||
async triggerPaste(windowId: number | undefined): Promise<void> {
|
||||
const window = this.windowById(windowId);
|
||||
async triggerPaste(windowId: number | undefined, options?: INativeHostOptions): Promise<void> {
|
||||
const window = this.windowById(options?.targetWindowId, windowId);
|
||||
return window?.win?.webContents.paste() ?? Promise.resolve();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,8 +20,8 @@ export class NativeClipboardService implements IClipboardService {
|
|||
@INativeHostService private readonly nativeHostService: INativeHostService
|
||||
) { }
|
||||
|
||||
async triggerPaste(): Promise<void> {
|
||||
return this.nativeHostService.triggerPaste();
|
||||
async triggerPaste(targetWindowId: number): Promise<void> {
|
||||
return this.nativeHostService.triggerPaste({ targetWindowId });
|
||||
}
|
||||
|
||||
async readImage(): Promise<Uint8Array> {
|
||||
|
|
|
@ -156,7 +156,7 @@ export class TestNativeHostService implements INativeHostService {
|
|||
async readClipboardFindText(): Promise<string> { return ''; }
|
||||
async writeClipboardFindText(text: string): Promise<void> { }
|
||||
async writeClipboardBuffer(format: string, buffer: VSBuffer, type?: 'selection' | 'clipboard' | undefined): Promise<void> { }
|
||||
async triggerPaste(): Promise<void> { }
|
||||
async triggerPaste(options?: INativeHostOptions): Promise<void> { }
|
||||
async readImage(): Promise<Uint8Array> { return Uint8Array.from([]); }
|
||||
async readClipboardBuffer(format: string): Promise<VSBuffer> { return VSBuffer.wrap(Uint8Array.from([])); }
|
||||
async hasClipboard(format: string, type?: 'selection' | 'clipboard' | undefined): Promise<boolean> { return false; }
|
||||
|
|
Loading…
Reference in New Issue