提交 4a380384 编写于 作者: P pi1024e

Added clear input method to clear disposables.

上级 16219067
......@@ -208,15 +208,15 @@ export class Sash extends Disposable {
}
}
if (!this.state) {
return;
}
if (this.state) {
// Select both iframes and webviews; internally Electron nests an iframe
// in its <webview> component, but this isn't queryable.
const iframes = [
...getElementsByTagName('iframe'),
...getElementsByTagName('webview'),
...getElementsByTagName('iframe'),
];
for (const iframe of iframes) {
......@@ -294,6 +294,8 @@ export class Sash extends Disposable {
domEvent(window, 'mousemove')(onMouseMove, null, disposables);
domEvent(window, 'mouseup')(onMouseUp, null, disposables);
}
}
private onMouseDoubleClick(event: MouseEvent): void {
this._onDidReset.fire();
......
......@@ -483,6 +483,13 @@ export class ExtensionEditor extends BaseEditor {
}));
}
clearInput(): void {
this.contentDisposables.clear();
this.transientDisposables.clear();
super.clearInput();
}
focus(): void {
if (this.activeElement) {
this.activeElement.focus();
......@@ -584,9 +591,7 @@ export class ExtensionEditor extends BaseEditor {
const content = $('div', { class: 'subcontent', tabindex: '0' });
return this.loadContents(() => this.extensionManifest!.get())
.then(manifest => {
if (!manifest) {
return content;
}
if (manifest) {
const scrollableContent = new DomScrollableElement(content, {});
......@@ -618,6 +623,7 @@ export class ExtensionEditor extends BaseEditor {
append(this.content, scrollableContent.getDomNode());
this.contentDisposables.add(scrollableContent);
}
}
return content;
}, () => {
append(content, $('p.nocontent')).textContent = localize('noContributions', "No Contributions");
......@@ -684,10 +690,7 @@ export class ExtensionEditor extends BaseEditor {
}
const contrib = properties ? Object.keys(properties) : [];
if (!contrib.length) {
return false;
}
if (contrib.length) {
const details = $('details', { open: true, ontoggle: onDetailsToggle },
$('summary', undefined, localize('settings', "Settings ({0})", contrib.length)),
$('table', undefined,
......@@ -707,15 +710,14 @@ export class ExtensionEditor extends BaseEditor {
append(container, details);
return true;
}
return false;
}
private renderDebuggers(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): boolean {
const contributes = manifest.contributes;
const contrib = contributes && contributes.debuggers || [];
if (!contrib.length) {
return false;
}
if (contrib.length) {
const details = $('details', { open: true, ontoggle: onDetailsToggle },
$('summary', undefined, localize('debuggers', "Debuggers ({0})", contrib.length)),
$('table', undefined,
......@@ -732,6 +734,8 @@ export class ExtensionEditor extends BaseEditor {
append(container, details);
return true;
}
return false;
}
private renderViewContainers(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): boolean {
const contributes = manifest.contributes;
......@@ -743,10 +747,7 @@ export class ExtensionEditor extends BaseEditor {
return result;
}, [] as Array<{ id: string, title: string, location: string }>);
if (!viewContainers.length) {
return false;
}
if (viewContainers.length) {
const details = $('details', { open: true, ontoggle: onDetailsToggle },
$('summary', undefined, localize('viewContainers', "View Containers ({0})", viewContainers.length)),
$('table', undefined,
......@@ -758,6 +759,8 @@ export class ExtensionEditor extends BaseEditor {
append(container, details);
return true;
}
return false;
}
private renderViews(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): boolean {
const contributes = manifest.contributes;
......@@ -769,10 +772,7 @@ export class ExtensionEditor extends BaseEditor {
return result;
}, [] as Array<{ id: string, name: string, location: string }>);
if (!views.length) {
return false;
}
if (views.length) {
const details = $('details', { open: true, ontoggle: onDetailsToggle },
$('summary', undefined, localize('views', "Views ({0})", views.length)),
$('table', undefined,
......@@ -784,6 +784,8 @@ export class ExtensionEditor extends BaseEditor {
append(container, details);
return true;
}
return false;
}
private renderLocalizations(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): boolean {
const contributes = manifest.contributes;
......@@ -843,9 +845,9 @@ export class ExtensionEditor extends BaseEditor {
const contributes = manifest.contributes;
const colors = contributes && contributes.colors;
if (!colors || !colors.length) {
return false;
}
if (colors && colors.length) {
function colorPreview(colorReference: string): Node[] {
let result: Node[] = [];
......@@ -882,16 +884,15 @@ export class ExtensionEditor extends BaseEditor {
append(container, details);
return true;
}
return false;
}
private renderJSONValidation(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): boolean {
const contributes = manifest.contributes;
const contrib = contributes && contributes.jsonValidation || [];
if (!contrib.length) {
return false;
}
if (contrib.length) {
const details = $('details', { open: true, ontoggle: onDetailsToggle },
$('summary', undefined, localize('JSON Validation', "JSON Validation ({0})", contrib.length)),
$('table', undefined,
......@@ -907,6 +908,8 @@ export class ExtensionEditor extends BaseEditor {
append(container, details);
return true;
}
return false;
}
private renderCommands(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): boolean {
const contributes = manifest.contributes;
......@@ -941,24 +944,23 @@ export class ExtensionEditor extends BaseEditor {
rawKeybindings.forEach(rawKeybinding => {
const keybinding = this.resolveKeybinding(rawKeybinding);
if (!keybinding) {
return;
}
if (keybinding) {
let command = byId[rawKeybinding.command];
if (!command) {
if (command) {
command.keybindings.push(keybinding);
} else {
command = { id: rawKeybinding.command, title: '', keybindings: [keybinding], menus: [] };
byId[command.id] = command;
commands.push(command);
} else {
command.keybindings.push(keybinding);
}
}
return;
});
if (!commands.length) {
return false;
}
if (commands.length) {
const renderKeybinding = (keybinding: ResolvedKeybinding): HTMLElement => {
const element = $('');
......@@ -987,6 +989,8 @@ export class ExtensionEditor extends BaseEditor {
append(container, details);
return true;
}
return false;
}
private renderLanguages(container: HTMLElement, manifest: IExtensionManifest, onDetailsToggle: Function): boolean {
const contributes = manifest.contributes;
......@@ -1006,12 +1010,12 @@ export class ExtensionEditor extends BaseEditor {
grammars.forEach(grammar => {
let language = byId[grammar.language];
if (!language) {
if (language) {
language.hasGrammar = true;
} else {
language = { id: grammar.language, name: grammar.language, extensions: [], hasGrammar: true, hasSnippets: false };
byId[language.id] = language;
languages.push(language);
} else {
language.hasGrammar = true;
}
});
......@@ -1020,19 +1024,16 @@ export class ExtensionEditor extends BaseEditor {
snippets.forEach(snippet => {
let language = byId[snippet.language];
if (!language) {
if (language) {
language.hasSnippets = true;
} else {
language = { id: snippet.language, name: snippet.language, extensions: [], hasGrammar: false, hasSnippets: true };
byId[language.id] = language;
languages.push(language);
} else {
language.hasSnippets = true;
}
});
if (!languages.length) {
return false;
}
if (languages.length) {
const details = $('details', { open: true, ontoggle: onDetailsToggle },
$('summary', undefined, localize('languages', "Languages ({0})", languages.length)),
$('table', undefined,
......@@ -1056,6 +1057,8 @@ export class ExtensionEditor extends BaseEditor {
append(container, details);
return true;
}
return false;
}
private resolveKeybinding(rawKeyBinding: IKeyBinding): ResolvedKeybinding | null {
let key: string | undefined;
......@@ -1067,12 +1070,11 @@ export class ExtensionEditor extends BaseEditor {
}
const keyBinding = KeybindingParser.parseKeybinding(key || rawKeyBinding.key, OS);
if (!keyBinding) {
return null;
}
if (keyBinding) {
return this.keybindingService.resolveKeybinding(keyBinding)[0];
}
return null;
}
private loadContents<T>(loadingTask: () => CacheResult<T>): Promise<T> {
addClass(this.content, 'loading');
......@@ -1094,7 +1096,6 @@ export class ExtensionEditor extends BaseEditor {
if (isPromiseCanceledError(err)) {
return;
}
this.notificationService.error(err);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册