提交 b4693045 编写于 作者: M Matt Bierner

Use async for releaseNotesEditor

上级 5bb04d68
......@@ -62,9 +62,9 @@ export class ReleaseNotesEditor extends WebviewEditor {
this.content = append(container, $('.release-notes', { 'style': 'height: 100%; position: relative; overflow: hidden;' }));
}
setInput(input: ReleaseNotesInput, options: EditorOptions): TPromise<void> {
async setInput(input: ReleaseNotesInput, options: EditorOptions): TPromise<void> {
if (this.input && this.input.matches(input)) {
return TPromise.as(undefined);
return undefined;
}
const { text } = input;
......@@ -72,48 +72,42 @@ export class ReleaseNotesEditor extends WebviewEditor {
this.contentDisposables = dispose(this.contentDisposables);
this.content.innerHTML = '';
return super.setInput(input, options)
.then(() => {
const result = [];
const renderer = new marked.Renderer();
renderer.code = (code, lang) => {
const modeId = this.modeService.getModeIdForLanguageName(lang);
result.push(this.modeService.getOrCreateMode(modeId));
return '';
};
marked(text, { renderer });
return TPromise.join(result);
}).then(() => {
const renderer = new marked.Renderer();
renderer.code = (code, lang) => {
const modeId = this.modeService.getModeIdForLanguageName(lang);
return `<code>${tokenizeToString(code, modeId)}</code>`;
};
return marked(text, { renderer });
})
.then(renderBody)
.then<void>(body => {
this._webview = new WebView(this.content, this.partService.getContainer(Parts.EDITOR_PART), this._contextViewService, this.contextKey);
if (this.input && this.input instanceof ReleaseNotesInput) {
const state = this.loadViewState(this.input.version);
if (state) {
this._webview.initialScrollProgress = state.scrollYPercentage;
}
}
this.onThemeChange(this.themeService.getTheme());
this._webview.contents = [body];
this._webview.onDidClickLink(link => this.openerService.open(link), null, this.contentDisposables);
this._webview.onDidScroll(event => {
this.scrollYPercentage = event.scrollYPercentage;
}, null, this.contentDisposables);
this.themeService.onThemeChange(this.onThemeChange, this, this.contentDisposables);
this.contentDisposables.push(this._webview);
this.contentDisposables.push(toDisposable(() => this._webview = null));
});
await super.setInput(input, options);
const result = [];
const renderer = new marked.Renderer();
renderer.code = (code, lang) => {
const modeId = this.modeService.getModeIdForLanguageName(lang);
result.push(this.modeService.getOrCreateMode(modeId));
return '';
};
marked(text, { renderer });
await TPromise.join(result);
renderer.code = (code, lang) => {
const modeId = this.modeService.getModeIdForLanguageName(lang);
return `<code>${tokenizeToString(code, modeId)}</code>`;
};
const body = renderBody(marked(text, { renderer }));
this._webview = new WebView(this.content, this.partService.getContainer(Parts.EDITOR_PART), this._contextViewService, this.contextKey);
if (this.input && this.input instanceof ReleaseNotesInput) {
const state = this.loadViewState(this.input.version);
if (state) {
this._webview.initialScrollProgress = state.scrollYPercentage;
}
}
this.onThemeChange(this.themeService.getTheme());
this._webview.contents = [body];
this._webview.onDidClickLink(link => this.openerService.open(link), null, this.contentDisposables);
this._webview.onDidScroll(event => {
this.scrollYPercentage = event.scrollYPercentage;
}, null, this.contentDisposables);
this.themeService.onThemeChange(this.onThemeChange, this, this.contentDisposables);
this.contentDisposables.push(this._webview);
this.contentDisposables.push(toDisposable(() => this._webview = null));
}
layout(): void {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册