提交 e0cc8f57 编写于 作者: R Rob Lourens

Queue replace actions within a filematch because other matches in the file...

Queue replace actions within a filematch because other matches in the file should be considered stale after one replace has been executed
Fix #88282
上级 33d38a9b
......@@ -683,6 +683,8 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction {
static readonly LABEL = nls.localize('match.replace.label', "Replace");
static runQ = Promise.resolve();
constructor(private viewer: WorkbenchObjectTree<RenderableMatch>, private element: Match, private viewlet: SearchView,
@IReplaceService private readonly replaceService: IReplaceService,
@IKeybindingService keyBindingService: IKeybindingService,
......@@ -691,26 +693,24 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction {
super(Constants.ReplaceActionId, appendKeyBindingLabel(ReplaceAction.LABEL, keyBindingService.lookupKeybinding(Constants.ReplaceActionId), keyBindingService), searchReplaceIcon.classNames);
}
run(): Promise<any> {
async run(): Promise<any> {
this.enabled = false;
return this.element.parent().replace(this.element).then(() => {
const elementToFocus = this.getElementToFocusAfterReplace();
if (elementToFocus) {
this.viewer.setFocus([elementToFocus], getSelectionKeyboardEvent());
}
await this.element.parent().replace(this.element);
const elementToFocus = this.getElementToFocusAfterReplace();
if (elementToFocus) {
this.viewer.setFocus([elementToFocus], getSelectionKeyboardEvent());
}
return this.getElementToShowReplacePreview(elementToFocus);
}).then(elementToShowReplacePreview => {
this.viewer.domFocus();
const elementToShowReplacePreview = this.getElementToShowReplacePreview(elementToFocus);
this.viewer.domFocus();
const useReplacePreview = this.configurationService.getValue<ISearchConfiguration>().search.useReplacePreview;
if (!useReplacePreview || !elementToShowReplacePreview || this.hasToOpenFile()) {
this.viewlet.open(this.element, true);
} else {
this.replaceService.openReplacePreview(elementToShowReplacePreview, true);
}
});
const useReplacePreview = this.configurationService.getValue<ISearchConfiguration>().search.useReplacePreview;
if (!useReplacePreview || !elementToShowReplacePreview || this.hasToOpenFile()) {
this.viewlet.open(this.element, true);
} else {
this.replaceService.openReplacePreview(elementToShowReplacePreview, true);
}
}
private getElementToFocusAfterReplace(): RenderableMatch {
......@@ -740,11 +740,11 @@ export class ReplaceAction extends AbstractSearchAndReplaceAction {
return elementToFocus!;
}
private async getElementToShowReplacePreview(elementToFocus: RenderableMatch): Promise<Match | null> {
private getElementToShowReplacePreview(elementToFocus: RenderableMatch): Match | null {
if (this.hasSameParent(elementToFocus)) {
return <Match>elementToFocus;
}
const previousElement = await this.getPreviousElementAfterRemoved(this.viewer, this.element);
const previousElement = this.getPreviousElementAfterRemoved(this.viewer, this.element);
if (this.hasSameParent(previousElement)) {
return <Match>previousElement;
}
......
......@@ -360,9 +360,12 @@ export class FileMatch extends Disposable implements IFileMatch {
this._onChange.fire({ didRemove: true });
}
replace(toReplace: Match): Promise<void> {
return this.replaceService.replace(toReplace)
.then(() => this.updatesMatchesForLineAfterReplace(toReplace.range().startLineNumber, false));
private replaceQ = Promise.resolve();
async replace(toReplace: Match): Promise<void> {
return this.replaceQ = this.replaceQ.finally(async () => {
await this.replaceService.replace(toReplace);
this.updatesMatchesForLineAfterReplace(toReplace.range().startLineNumber, false);
});
}
setSelectedMatch(match: Match | null): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册