提交 4de13ca8 编写于 作者: J Joao Moreno

CountBadge is not disposable

上级 e6361268
......@@ -6,42 +6,33 @@
'use strict';
import 'vs/css!./countBadge';
import { Builder, $ } from 'vs/base/browser/builder';
import strings = require('vs/base/common/strings');
import { $, append } from 'vs/base/browser/dom';
import { format } from 'vs/base/common/strings';
export class CountBadge {
private $el: Builder;
private element: HTMLElement;
private count: number;
private titleFormat: string;
constructor(container: Builder, count?: number, titleFormat?: string);
constructor(container: HTMLElement, count?: number, titleFormat?: string);
constructor(container: any, count?: number, titleFormat?: string) {
this.$el = $('.monaco-count-badge').appendTo(container);
constructor(container: HTMLElement, count?: number, titleFormat?: string) {
this.element = append(container, $('.monaco-count-badge'));
this.titleFormat = titleFormat || '';
this.setCount(count || 0);
}
public setCount(count: number) {
setCount(count: number) {
this.count = count;
this.render();
}
public setTitleFormat(titleFormat: string) {
setTitleFormat(titleFormat: string) {
this.titleFormat = titleFormat;
this.render();
}
private render() {
this.$el.text('' + this.count);
this.$el.title(strings.format(this.titleFormat, this.count));
}
public dispose() {
if (this.$el) {
this.$el.destroy();
this.$el = null;
}
this.element.textContent = '' + this.count;
this.element.title = format(this.titleFormat, this.count);
}
}
......@@ -379,7 +379,7 @@ class Renderer extends LegacyRenderer {
badge.setTitleFormat(nls.localize('referenceCount', "{0} reference", len));
}
return badge;
return null;
});
/* tslint:enable:no-unused-expression */
......
......@@ -149,7 +149,8 @@ export class SearchRenderer extends ActionsRenderer {
rightRenderer = (right: HTMLElement) => {
let len = fileMatch.count();
return new CountBadge(right, len, len > 1 ? nls.localize('searchMatches', "{0} matches found", len) : nls.localize('searchMatch', "{0} match found", len));
new CountBadge(right, len, len > 1 ? nls.localize('searchMatches', "{0} matches found", len) : nls.localize('searchMatch', "{0} match found", len));
return null;
};
widget = new LeftRightWidget(container, leftRenderer, rightRenderer);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册