|
6 | 6 | import { Disposable } from 'vs/base/common/lifecycle';
|
7 | 7 | import { Schemas } from 'vs/base/common/network';
|
8 | 8 | import { URI } from 'vs/base/common/uri';
|
9 |
| -import { IEditorContribution } from 'vs/editor/common/editorCommon'; |
| 9 | +import { ICodeEditor } from 'vs/editor/browser/editorBrowser'; |
| 10 | +import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService'; |
| 11 | +import { IEditorContribution, ScrollType } from 'vs/editor/common/editorCommon'; |
10 | 12 | import { ILanguageService } from 'vs/editor/common/languages/language';
|
11 | 13 | import { ITextModel } from 'vs/editor/common/model';
|
12 | 14 | import { IModelService } from 'vs/editor/common/services/model';
|
13 | 15 | import { ITextModelContentProvider, ITextModelService } from 'vs/editor/common/services/resolverService';
|
| 16 | +import { ITextResourceEditorInput } from 'vs/platform/editor/common/editor'; |
| 17 | +import { applyTextEditorOptions } from 'vs/workbench/common/editor/editorOptions'; |
| 18 | +import { SimpleCommentEditor } from 'vs/workbench/contrib/comments/browser/simpleCommentEditor'; |
14 | 19 |
|
15 | 20 | export class CommentsInputContentProvider extends Disposable implements ITextModelContentProvider, IEditorContribution {
|
16 | 21 |
|
17 | 22 | public static readonly ID = 'comments.input.contentProvider';
|
18 | 23 |
|
19 | 24 | constructor(
|
20 | 25 | @ITextModelService textModelService: ITextModelService,
|
| 26 | + @ICodeEditorService codeEditorService: ICodeEditorService, |
21 | 27 | @IModelService private readonly _modelService: IModelService,
|
22 | 28 | @ILanguageService private readonly _languageService: ILanguageService,
|
23 | 29 | ) {
|
24 | 30 | super();
|
25 | 31 | this._register(textModelService.registerTextModelContentProvider(Schemas.commentsInput, this));
|
| 32 | + |
| 33 | + this._register(codeEditorService.registerCodeEditorOpenHandler(async (input: ITextResourceEditorInput, editor: ICodeEditor | null, _sideBySide?: boolean): Promise<ICodeEditor | null> => { |
| 34 | + if (!(editor instanceof SimpleCommentEditor)) { |
| 35 | + return null; |
| 36 | + } |
| 37 | + |
| 38 | + if (editor.getModel()?.uri.toString() !== input.resource.toString()) { |
| 39 | + return null; |
| 40 | + } |
| 41 | + |
| 42 | + if (input.options) { |
| 43 | + applyTextEditorOptions(input.options, editor, ScrollType.Immediate); |
| 44 | + } |
| 45 | + return editor; |
| 46 | + })); |
26 | 47 | }
|
27 | 48 |
|
28 | 49 | async provideTextContent(resource: URI): Promise<ITextModel | null> {
|
|
0 commit comments