forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose comments input as text document
Fixes https://github.com/microsoft/vscode-pull-request-github/issues/5875 For microsoft#209508 Exposes comment input editors as text documents that extensions can see. Enables a few features in them too such as 'paste as' and 'drop into'
- Loading branch information
Showing
7 changed files
with
117 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/vs/workbench/contrib/comments/browser/commentsInputContentProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { Disposable } from 'vs/base/common/lifecycle'; | ||
import { Schemas } from 'vs/base/common/network'; | ||
import { URI } from 'vs/base/common/uri'; | ||
import { IEditorContribution } from 'vs/editor/common/editorCommon'; | ||
import { ILanguageService } from 'vs/editor/common/languages/language'; | ||
import { ITextModel } from 'vs/editor/common/model'; | ||
import { IModelService } from 'vs/editor/common/services/model'; | ||
import { ITextModelContentProvider, ITextModelService } from 'vs/editor/common/services/resolverService'; | ||
|
||
export class CommentsInputContentProvider extends Disposable implements ITextModelContentProvider, IEditorContribution { | ||
|
||
public static readonly ID = 'comments.input.contentProvider'; | ||
|
||
constructor( | ||
@ITextModelService textModelService: ITextModelService, | ||
@IModelService private readonly _modelService: IModelService, | ||
@ILanguageService private readonly _languageService: ILanguageService, | ||
) { | ||
super(); | ||
this._register(textModelService.registerTextModelContentProvider(Schemas.commentsInput, this)); | ||
} | ||
|
||
async provideTextContent(resource: URI): Promise<ITextModel | null> { | ||
const existing = this._modelService.getModel(resource); | ||
return existing ?? this._modelService.createModel('', this._languageService.createById('markdown'), resource); | ||
} | ||
} |
Oops, something went wrong.