提交 afc8f390 编写于 作者: S Sandeep Somavarapu

fix #8335

上级 ebc878d6
......@@ -23,10 +23,12 @@ import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
class EditorInputCache {
private cache: Map.SimpleMap<URI, TPromise<DiffEditorInput>>;
private replaceTextcache: Map.SimpleMap<URI, string>;
constructor(private replaceService: ReplaceService, private editorService: IWorkbenchEditorService,
private modelService: IModelService) {
this.cache= new Map.SimpleMap<URI, TPromise<DiffEditorInput>>();
this.replaceTextcache= new Map.SimpleMap<URI, string>();
}
public getInput(fileMatch: FileMatch, text: string): TPromise<DiffEditorInput> {
......@@ -36,6 +38,7 @@ class EditorInputCache {
this.cache.set(fileMatch.resource(), editorInputPromise);
this.refreshInput(fileMatch, text, true);
fileMatch.addListener2('disposed', fileMatch => this.disposeInput(fileMatch));
fileMatch.addListener2('changed', fileMatch => this.refreshInput(fileMatch, this.replaceTextcache.get(fileMatch.resource()), false));
}
return editorInputPromise;
}
......@@ -55,6 +58,7 @@ class EditorInputCache {
this.modelService.getModel(replaceResource).undo();
this.replaceService.replace(fileMatch, text, null, replaceResource);
}
this.replaceTextcache.set(fileMatch.resource(), text);
});
}
}
......@@ -69,6 +73,7 @@ class EditorInputCache {
editorInputPromise.done((diffInput) => {
this.disposeReplaceInput(this.getReplaceResource(resourceUri), diffInput);
this.cache.delete(resourceUri);
this.replaceTextcache.delete(resourceUri);
});
}
}
......@@ -141,9 +146,11 @@ export class ReplaceService implements IReplaceService {
if (arg instanceof Array) {
arg.forEach(element => {
let fileMatch = <FileMatch>element;
fileMatch.matches().forEach(match => {
bulkEdit.add([this.createEdit(match, text, resource)]);
});
if (fileMatch.count() > 0) {
fileMatch.matches().forEach(match => {
bulkEdit.add([this.createEdit(match, text, resource)]);
});
}
});
}
......
......@@ -98,6 +98,7 @@ export class FileMatch extends EventEmitter implements lifecycle.IDisposable {
public add(match: Match): void {
this._matches[match.id()] = match;
this.emit('changed', this);
}
public remove(match: Match): void {
......@@ -106,6 +107,7 @@ export class FileMatch extends EventEmitter implements lifecycle.IDisposable {
if (this.count() === 0) {
this.add(new EmptyMatch(this));
}
this.emit('changed', this);
}
public matches(): Match[] {
......@@ -217,6 +219,10 @@ export class LiveFileMatch extends FileMatch implements lifecycle.IDisposable {
return !this._model || (<ITextModel>this._model).isDisposed();
}
public remove(match: Match): void {
super.remove(match);
this._diskFileMatch.remove(match);
}
}
export class SearchResult extends EventEmitter {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册