show comments in diff view sidebyside.

This commit is contained in:
rebornix
2018-06-13 15:48:25 -07:00
parent 7e31284d4c
commit f83a748a8e
2 changed files with 36 additions and 16 deletions

View File

@@ -5,7 +5,7 @@
'use strict';
import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ICodeEditor, getCodeEditor } from 'vs/editor/browser/editorBrowser';
import { ICodeEditor, isCodeEditor, isDiffEditor, getCodeEditor, IDiffEditor } from 'vs/editor/browser/editorBrowser';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import * as modes from 'vs/editor/common/modes';
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
@@ -37,23 +37,25 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this._disposables = [];
this._proxy = extHostContext.getProxy(ExtHostContext.ExtHostComments);
this._disposables.push(this._editorService.onDidActiveEditorChange(e => {
const outerEditor = this.getFocusedEditor();
if (!outerEditor) {
const editors = this.getFocusedEditors();
if (!editors || !editors.length) {
return;
}
const controller = ReviewController.get(outerEditor);
if (!controller) {
return;
}
editors.forEach(editor => {
const controller = ReviewController.get(editor);
if (!controller) {
return;
}
if (!outerEditor.getModel()) {
return;
}
if (!editor.getModel()) {
return;
}
const outerEditorURI = outerEditor.getModel().uri;
this.provideDocumentComments(outerEditorURI).then(commentInfos => {
this._commentService.setDocumentComments(outerEditorURI, commentInfos.filter(info => info !== null));
const outerEditorURI = editor.getModel().uri;
this.provideDocumentComments(outerEditorURI).then(commentInfos => {
this._commentService.setDocumentComments(outerEditorURI, commentInfos.filter(info => info !== null));
});
});
}));
}
@@ -115,8 +117,25 @@ export class MainThreadComments extends Disposable implements MainThreadComments
this._documentProviders.clear();
}
getFocusedEditor(): ICodeEditor {
return this._codeEditorService.getFocusedCodeEditor() || getCodeEditor(this._editorService.activeControl);
getFocusedEditors(): ICodeEditor[] {
let activeControl = this._editorService.activeControl;
if (activeControl) {
if (isCodeEditor(activeControl.getControl())) {
return [this._editorService.activeControl.getControl() as ICodeEditor];
}
if (isDiffEditor(activeControl.getControl())) {
let diffEditor = activeControl.getControl() as IDiffEditor;
return [diffEditor.getOriginalEditor(), diffEditor.getModifiedEditor()];
}
}
let editor = this._codeEditorService.getFocusedCodeEditor();
if (editor) {
return [editor];
}
return [];
}
async provideWorkspaceComments(): Promise<modes.CommentThread[]> {