Skip to content

Commit

Permalink
handle diff editor for comments population.
Browse files Browse the repository at this point in the history
  • Loading branch information
rebornix committed Jun 8, 2018
1 parent 861816b commit 4c11f8c
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/vs/workbench/api/electron-browser/mainThreadComments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'use strict';

import { Disposable, IDisposable, dispose } from 'vs/base/common/lifecycle';
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { ICodeEditor, 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';
Expand Down Expand Up @@ -116,7 +116,17 @@ export class MainThreadComments extends Disposable implements MainThreadComments
getFocusedEditor(): ICodeEditor {
let editor = this._codeEditorService.getFocusedCodeEditor();
if (!editor) {
return this._editorService.activeTextEditorWidget as ICodeEditor;
/* please note that the type of `this._editorService.activeTextEditorWidget` is `{ IEditor as ICodeEditor } from 'vs/editor/common/editorCommon'`
* It's `IEditor` but renamed to `ICodeEditor`. The `ICodeEditor` in current context is `import { ICodeEditor } from 'vs/editor/browser/editorBrowser'`
* this._editorService.activeTextEditorWidget is
* 1. ICodeEditor extends editorCommon.IEditor
* 2. IDiffEditor extends editorCommon.IEditor
*/
if ((this._editorService.activeTextEditorWidget as ICodeEditor).getContribution) {
return this._editorService.activeTextEditorWidget as ICodeEditor;
} else {
return (this._editorService.activeTextEditorWidget as IDiffEditor).getModifiedEditor();
}
}

return editor;
Expand Down

0 comments on commit 4c11f8c

Please sign in to comment.