提交 34e74ba1 编写于 作者: A Alex Dima

Tweak the way find decorations are managed

上级 69ab7b14
...@@ -132,29 +132,32 @@ export class FindDecorations implements IDisposable { ...@@ -132,29 +132,32 @@ export class FindDecorations implements IDisposable {
} }
public set(findMatches: editorCommon.FindMatch[], findScope: Range): void { public set(findMatches: editorCommon.FindMatch[], findScope: Range): void {
let newDecorations: editorCommon.IModelDeltaDecoration[] = new Array<editorCommon.IModelDeltaDecoration>(findMatches.length); this._editor.changeDecorations((accessor) => {
for (let i = 0, len = findMatches.length; i < len; i++) { // Find matches
newDecorations[i] = { let newFindMatchesDecorations: editorCommon.IModelDeltaDecoration[] = new Array<editorCommon.IModelDeltaDecoration>(findMatches.length);
range: findMatches[i].range, for (let i = 0, len = findMatches.length; i < len; i++) {
options: FindDecorations._FIND_MATCH_DECORATION newFindMatchesDecorations[i] = {
}; range: findMatches[i].range,
} options: FindDecorations._FIND_MATCH_DECORATION
if (findScope) { };
newDecorations.unshift({ }
range: findScope, this._decorations = accessor.deltaDecorations(this._decorations, newFindMatchesDecorations);
options: FindDecorations._FIND_SCOPE_DECORATION
});
}
let tmpDecorations = this._editor.deltaDecorations(this._allDecorations(), newDecorations);
if (findScope) { // Range highlight
this._findScopeDecorationId = tmpDecorations.shift(); if (this._rangeHighlightDecorationId) {
} else { accessor.removeDecoration(this._rangeHighlightDecorationId);
this._findScopeDecorationId = null; this._rangeHighlightDecorationId = null;
} }
this._decorations = tmpDecorations;
this._rangeHighlightDecorationId = null; // Find scope
this._highlightedDecorationId = null; if (this._findScopeDecorationId) {
accessor.removeDecoration(this._findScopeDecorationId);
this._findScopeDecorationId = null;
}
if (findScope) {
this._findScopeDecorationId = accessor.addDecoration(findScope, FindDecorations._FIND_SCOPE_DECORATION);
}
});
} }
private _allDecorations(): string[] { private _allDecorations(): string[] {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册