未验证 提交 fc4b55ee 编写于 作者: B Benjamin Pasero 提交者: GitHub

Clipboard: sync access is deprecated (fix #98556) (#100467)

上级 b015e717
......@@ -255,7 +255,7 @@ export class CommonFindController extends Disposable implements IEditorContribut
// overwritten in subclass
}
protected _start(opts: IFindStartOptions): void {
protected async _start(opts: IFindStartOptions): Promise<void> {
this.disposeModel();
if (!this._editor.hasModel()) {
......@@ -279,7 +279,7 @@ export class CommonFindController extends Disposable implements IEditorContribut
}
if (!stateChanges.searchString && opts.seedSearchStringFromGlobalClipboard) {
let selectionSearchString = this.getGlobalBufferTerm();
let selectionSearchString = await this.getGlobalBufferTerm();
if (selectionSearchString) {
stateChanges.searchString = selectionSearchString;
}
......@@ -308,8 +308,8 @@ export class CommonFindController extends Disposable implements IEditorContribut
}
}
public start(opts: IFindStartOptions): void {
this._start(opts);
public start(opts: IFindStartOptions): Promise<void> {
return this._start(opts);
}
public moveToNextMatch(): boolean {
......@@ -353,24 +353,24 @@ export class CommonFindController extends Disposable implements IEditorContribut
return false;
}
public getGlobalBufferTerm(): string {
public async getGlobalBufferTerm(): Promise<string> {
if (this._editor.getOption(EditorOption.find).globalFindClipboard
&& this._clipboardService
&& this._editor.hasModel()
&& !this._editor.getModel().isTooLargeForSyncing()
) {
return this._clipboardService.readFindTextSync();
return this._clipboardService.readFindText();
}
return '';
}
public setGlobalBufferTerm(text: string) {
public async setGlobalBufferTerm(text: string) {
if (this._editor.getOption(EditorOption.find).globalFindClipboard
&& this._clipboardService
&& this._editor.hasModel()
&& !this._editor.getModel().isTooLargeForSyncing()
) {
this._clipboardService.writeFindTextSync(text);
await this._clipboardService.writeFindText(text);
}
}
}
......@@ -396,7 +396,7 @@ export class FindController extends CommonFindController implements IFindControl
this._findOptionsWidget = null;
}
protected _start(opts: IFindStartOptions): void {
protected async _start(opts: IFindStartOptions): Promise<void> {
if (!this._widget) {
this._createFindWidget();
}
......@@ -422,7 +422,7 @@ export class FindController extends CommonFindController implements IFindControl
opts.updateSearchScope = updateSearchScope;
super._start(opts);
await super._start(opts);
if (opts.shouldFocus === FindStartFocusAction.FocusReplaceInput) {
this._widget!.focusReplaceInput();
......@@ -505,7 +505,7 @@ export class StartFindWithSelectionAction extends EditorAction {
});
}
public run(accessor: ServicesAccessor, editor: ICodeEditor): void {
public async run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
let controller = CommonFindController.get(editor);
if (controller) {
controller.start({
......@@ -518,7 +518,7 @@ export class StartFindWithSelectionAction extends EditorAction {
loop: editor.getOption(EditorOption.find).loop
});
controller.setGlobalBufferTerm(controller.getState().searchString);
return controller.setGlobalBufferTerm(controller.getState().searchString);
}
}
}
......
......@@ -52,7 +52,7 @@ export const findNextMatchIcon = registerIcon('find-next-match', Codicon.arrowDo
export interface IFindController {
replace(): void;
replaceAll(): void;
getGlobalBufferTerm(): string;
getGlobalBufferTerm(): Promise<string>;
}
const NLS_FIND_INPUT_LABEL = nls.localize('label.find', "Find");
......@@ -224,9 +224,9 @@ export class FindWidget extends Widget implements IOverlayWidget, IVerticalSashL
this._updateToggleSelectionFindButton();
}
}));
this._register(this._codeEditor.onDidFocusEditorWidget(() => {
this._register(this._codeEditor.onDidFocusEditorWidget(async () => {
if (this._isVisible) {
let globalBufferTerm = this._controller.getGlobalBufferTerm();
let globalBufferTerm = await this._controller.getGlobalBufferTerm();
if (globalBufferTerm && globalBufferTerm !== this._state.searchString) {
this._state.change({ searchString: globalBufferTerm }, true);
this._findInput.select();
......
......@@ -39,8 +39,8 @@ export class TestFindController extends CommonFindController {
this.hasFocus = false;
}
protected _start(opts: IFindStartOptions): void {
super._start(opts);
protected async _start(opts: IFindStartOptions): Promise<void> {
await super._start(opts);
if (opts.shouldFocus !== FindStartFocusAction.NoFocusChange) {
this.hasFocus = true;
......
......@@ -97,14 +97,4 @@ export class BrowserClipboardService implements IClipboardService {
async hasResources(): Promise<boolean> {
return this.resources.length > 0;
}
/** @deprecated */
readFindTextSync(): string {
return this.findText;
}
/** @deprecated */
writeFindTextSync(text: string): void {
this.findText = text;
}
}
......@@ -46,12 +46,4 @@ export interface IClipboardService {
* Find out if resources are copied to the clipboard.
*/
hasResources(): Promise<boolean>;
/** @deprecated */
readFindTextSync(): string;
/** @deprecated */
writeFindTextSync(text: string): void;
}
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { clipboard } from 'electron';
import { URI } from 'vs/base/common/uri';
import { isMacintosh } from 'vs/base/common/platform';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
......@@ -77,22 +76,6 @@ export class NativeClipboardService implements IClipboardService {
return []; // do not trust clipboard data
}
}
/** @deprecated */
readFindTextSync(): string {
if (isMacintosh) {
return clipboard.readFindText();
}
return '';
}
/** @deprecated */
writeFindTextSync(text: string): void {
if (isMacintosh) {
clipboard.writeFindText(text);
}
}
}
registerSingleton(IClipboardService, NativeClipboardService, true);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册