Merge pull request #270422 from mjbvz/dev/mjbvz/unconscious-pinniped

Remove markdown code block font family option
This commit is contained in:
Matt Bierner
2025-10-08 12:29:30 -07:00
committed by GitHub
12 changed files with 37 additions and 71 deletions

View File

@@ -10,8 +10,6 @@ import * as dom from '../../../../base/browser/dom.js';
import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js'; import { IKeybindingService } from '../../../../platform/keybinding/common/keybinding.js';
import { KeyCode } from '../../../../base/common/keyCodes.js'; import { KeyCode } from '../../../../base/common/keyCodes.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js'; import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { IEditorOptions } from '../../../common/config/editorOptions.js';
import { EDITOR_FONT_DEFAULTS } from '../../../common/config/fontInfo.js';
import { HoverAction, HoverPosition, HoverWidget as BaseHoverWidget, getHoverAccessibleViewHint } from '../../../../base/browser/ui/hover/hoverWidget.js'; import { HoverAction, HoverPosition, HoverWidget as BaseHoverWidget, getHoverAccessibleViewHint } from '../../../../base/browser/ui/hover/hoverWidget.js';
import { Widget } from '../../../../base/browser/ui/widget.js'; import { Widget } from '../../../../base/browser/ui/widget.js';
import { AnchorPosition } from '../../../../base/browser/ui/contextview/contextview.js'; import { AnchorPosition } from '../../../../base/browser/ui/contextview/contextview.js';
@@ -167,10 +165,7 @@ export class HoverWidget extends Widget implements IHoverWidget {
} else { } else {
const markdown = options.content; const markdown = options.content;
const mdRenderer = this._instantiationService.createInstance( const mdRenderer = this._instantiationService.createInstance(MarkdownRenderer, {});
MarkdownRenderer,
{ codeBlockFontFamily: this._configurationService.getValue<IEditorOptions>('editor').fontFamily || EDITOR_FONT_DEFAULTS.fontFamily }
);
const { element, dispose } = mdRenderer.render(markdown, { const { element, dispose } = mdRenderer.render(markdown, {
actionHandler: (content) => this._linkHandler(content), actionHandler: (content) => this._linkHandler(content),

View File

@@ -8,8 +8,10 @@ import { createTrustedTypesPolicy } from '../../../../../base/browser/trustedTyp
import { onUnexpectedError } from '../../../../../base/common/errors.js'; import { onUnexpectedError } from '../../../../../base/common/errors.js';
import { IMarkdownString, MarkdownStringTrustedOptions } from '../../../../../base/common/htmlContent.js'; import { IMarkdownString, MarkdownStringTrustedOptions } from '../../../../../base/common/htmlContent.js';
import { IDisposable } from '../../../../../base/common/lifecycle.js'; import { IDisposable } from '../../../../../base/common/lifecycle.js';
import { IConfigurationService } from '../../../../../platform/configuration/common/configuration.js';
import { IOpenerService } from '../../../../../platform/opener/common/opener.js'; import { IOpenerService } from '../../../../../platform/opener/common/opener.js';
import { EditorOption } from '../../../../common/config/editorOptions.js'; import { EditorOption, IEditorOptions } from '../../../../common/config/editorOptions.js';
import { EDITOR_FONT_DEFAULTS } from '../../../../common/config/fontInfo.js';
import { ILanguageService } from '../../../../common/languages/language.js'; import { ILanguageService } from '../../../../common/languages/language.js';
import { PLAINTEXT_LANGUAGE_ID } from '../../../../common/languages/modesRegistry.js'; import { PLAINTEXT_LANGUAGE_ID } from '../../../../common/languages/modesRegistry.js';
import { tokenizeToString } from '../../../../common/languages/textToHtmlTokenizer.js'; import { tokenizeToString } from '../../../../common/languages/textToHtmlTokenizer.js';
@@ -23,7 +25,6 @@ export interface IMarkdownRenderResult extends IDisposable {
export interface IMarkdownRendererOptions { export interface IMarkdownRendererOptions {
readonly editor?: ICodeEditor; readonly editor?: ICodeEditor;
readonly codeBlockFontFamily?: string;
readonly codeBlockFontSize?: string; readonly codeBlockFontSize?: string;
} }
@@ -41,6 +42,7 @@ export class MarkdownRenderer {
constructor( constructor(
private readonly _options: IMarkdownRendererOptions, private readonly _options: IMarkdownRendererOptions,
@IConfigurationService private readonly _configurationService: IConfigurationService,
@ILanguageService private readonly _languageService: ILanguageService, @ILanguageService private readonly _languageService: ILanguageService,
@IOpenerService private readonly _openerService: IOpenerService, @IOpenerService private readonly _openerService: IOpenerService,
) { } ) { }
@@ -78,8 +80,8 @@ export class MarkdownRenderer {
if (this._options.editor) { if (this._options.editor) {
const fontInfo = this._options.editor.getOption(EditorOption.fontInfo); const fontInfo = this._options.editor.getOption(EditorOption.fontInfo);
applyFontInfo(element, fontInfo); applyFontInfo(element, fontInfo);
} else if (this._options.codeBlockFontFamily) { } else {
element.style.fontFamily = this._options.codeBlockFontFamily; element.style.fontFamily = this._configurationService.getValue<IEditorOptions>('editor').fontFamily || EDITOR_FONT_DEFAULTS.fontFamily;
} }
if (this._options.codeBlockFontSize !== undefined) { if (this._options.codeBlockFontSize !== undefined) {

View File

@@ -8,13 +8,12 @@ import { Disposable, DisposableStore } from '../../../../base/common/lifecycle.j
import { MarkdownRenderer } from '../../../browser/widget/markdownRenderer/browser/markdownRenderer.js'; import { MarkdownRenderer } from '../../../browser/widget/markdownRenderer/browser/markdownRenderer.js';
import { ICodeEditor, IEditorMouseEvent, IOverlayWidget, IOverlayWidgetPosition, MouseTargetType } from '../../../browser/editorBrowser.js'; import { ICodeEditor, IEditorMouseEvent, IOverlayWidget, IOverlayWidgetPosition, MouseTargetType } from '../../../browser/editorBrowser.js';
import { ConfigurationChangedEvent, EditorOption } from '../../../common/config/editorOptions.js'; import { ConfigurationChangedEvent, EditorOption } from '../../../common/config/editorOptions.js';
import { ILanguageService } from '../../../common/languages/language.js';
import { HoverOperation, HoverResult, HoverStartMode } from './hoverOperation.js'; import { HoverOperation, HoverResult, HoverStartMode } from './hoverOperation.js';
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
import { HoverWidget } from '../../../../base/browser/ui/hover/hoverWidget.js'; import { HoverWidget } from '../../../../base/browser/ui/hover/hoverWidget.js';
import { IHoverWidget } from './hoverTypes.js'; import { IHoverWidget } from './hoverTypes.js';
import { IHoverMessage, LaneOrLineNumber, GlyphHoverComputer, GlyphHoverComputerOptions } from './glyphHoverComputer.js'; import { IHoverMessage, LaneOrLineNumber, GlyphHoverComputer, GlyphHoverComputerOptions } from './glyphHoverComputer.js';
import { isMousePositionWithinElement } from './hoverUtils.js'; import { isMousePositionWithinElement } from './hoverUtils.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
const $ = dom.$; const $ = dom.$;
@@ -36,8 +35,7 @@ export class GlyphHoverWidget extends Disposable implements IOverlayWidget, IHov
constructor( constructor(
editor: ICodeEditor, editor: ICodeEditor,
@ILanguageService languageService: ILanguageService, @IInstantiationService instantiationService: IInstantiationService,
@IOpenerService openerService: IOpenerService,
) { ) {
super(); super();
this._editor = editor; this._editor = editor;
@@ -48,7 +46,7 @@ export class GlyphHoverWidget extends Disposable implements IOverlayWidget, IHov
this._hover = this._register(new HoverWidget(true)); this._hover = this._register(new HoverWidget(true));
this._hover.containerDomNode.classList.toggle('hidden', !this._isVisible); this._hover.containerDomNode.classList.toggle('hidden', !this._isVisible);
this._markdownRenderer = new MarkdownRenderer({ editor: this._editor }, languageService, openerService); this._markdownRenderer = instantiationService.createInstance(MarkdownRenderer, { editor: this._editor });
this._hoverOperation = this._register(new HoverOperation(this._editor, new GlyphHoverComputer(this._editor))); this._hoverOperation = this._register(new HoverOperation(this._editor, new GlyphHoverComputer(this._editor)));
this._register(this._hoverOperation.onResult((result) => this._withResult(result))); this._register(this._hoverOperation.onResult((result) => this._withResult(result)));

View File

@@ -14,11 +14,9 @@ import { ICodeEditor } from '../../../browser/editorBrowser.js';
import { Position } from '../../../common/core/position.js'; import { Position } from '../../../common/core/position.js';
import { Range } from '../../../common/core/range.js'; import { Range } from '../../../common/core/range.js';
import { IModelDecoration, ITextModel } from '../../../common/model.js'; import { IModelDecoration, ITextModel } from '../../../common/model.js';
import { ILanguageService } from '../../../common/languages/language.js';
import { HoverAnchor, HoverAnchorType, HoverRangeAnchor, IEditorHoverParticipant, IEditorHoverRenderContext, IHoverPart, IRenderedHoverPart, IRenderedHoverParts, RenderedHoverParts } from './hoverTypes.js'; import { HoverAnchor, HoverAnchorType, HoverRangeAnchor, IEditorHoverParticipant, IEditorHoverRenderContext, IHoverPart, IRenderedHoverPart, IRenderedHoverParts, RenderedHoverParts } from './hoverTypes.js';
import * as nls from '../../../../nls.js'; import * as nls from '../../../../nls.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js'; import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
import { ILanguageFeaturesService } from '../../../common/services/languageFeatures.js'; import { ILanguageFeaturesService } from '../../../common/services/languageFeatures.js';
import { EditorOption } from '../../../common/config/editorOptions.js'; import { EditorOption } from '../../../common/config/editorOptions.js';
import { Hover, HoverContext, HoverProvider, HoverVerbosityAction } from '../../../common/languages.js'; import { Hover, HoverContext, HoverProvider, HoverVerbosityAction } from '../../../common/languages.js';
@@ -36,6 +34,7 @@ import { getHoverProviderResultsAsAsyncIterable } from './getHover.js';
import { ICommandService } from '../../../../platform/commands/common/commands.js'; import { ICommandService } from '../../../../platform/commands/common/commands.js';
import { HoverStartSource } from './hoverOperation.js'; import { HoverStartSource } from './hoverOperation.js';
import { ScrollEvent } from '../../../../base/common/scrollable.js'; import { ScrollEvent } from '../../../../base/common/scrollable.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
const $ = dom.$; const $ = dom.$;
const increaseHoverVerbosityIcon = registerIcon('hover-increase-verbosity', Codicon.add, nls.localize('increaseHoverVerbosity', 'Icon for increaseing hover verbosity.')); const increaseHoverVerbosityIcon = registerIcon('hover-increase-verbosity', Codicon.add, nls.localize('increaseHoverVerbosity', 'Icon for increaseing hover verbosity.'));
@@ -87,8 +86,7 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant<Markdow
constructor( constructor(
protected readonly _editor: ICodeEditor, protected readonly _editor: ICodeEditor,
@ILanguageService private readonly _languageService: ILanguageService, @IInstantiationService private readonly _instantiationService: IInstantiationService,
@IOpenerService private readonly _openerService: IOpenerService,
@IConfigurationService private readonly _configurationService: IConfigurationService, @IConfigurationService private readonly _configurationService: IConfigurationService,
@ILanguageFeaturesService protected readonly _languageFeaturesService: ILanguageFeaturesService, @ILanguageFeaturesService protected readonly _languageFeaturesService: ILanguageFeaturesService,
@IKeybindingService private readonly _keybindingService: IKeybindingService, @IKeybindingService private readonly _keybindingService: IKeybindingService,
@@ -186,12 +184,11 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant<Markdow
context.fragment, context.fragment,
this, this,
this._editor, this._editor,
this._languageService,
this._openerService,
this._commandService, this._commandService,
this._keybindingService, this._keybindingService,
this._hoverService, this._hoverService,
this._configurationService, this._configurationService,
this._instantiationService,
context.onContentsChanged context.onContentsChanged
); );
return this._renderedHoverParts; return this._renderedHoverParts;
@@ -245,12 +242,11 @@ class MarkdownRenderedHoverParts implements IRenderedHoverParts<MarkdownHover> {
hoverPartsContainer: DocumentFragment, hoverPartsContainer: DocumentFragment,
private readonly _hoverParticipant: MarkdownHoverParticipant, private readonly _hoverParticipant: MarkdownHoverParticipant,
private readonly _editor: ICodeEditor, private readonly _editor: ICodeEditor,
private readonly _languageService: ILanguageService,
private readonly _openerService: IOpenerService,
private readonly _commandService: ICommandService, private readonly _commandService: ICommandService,
private readonly _keybindingService: IKeybindingService, private readonly _keybindingService: IKeybindingService,
private readonly _hoverService: IHoverService, private readonly _hoverService: IHoverService,
private readonly _configurationService: IConfigurationService, private readonly _configurationService: IConfigurationService,
private readonly _instantiationService: IInstantiationService,
private readonly _onFinishedRendering: () => void, private readonly _onFinishedRendering: () => void,
) { ) {
this.renderedHoverParts = this._renderHoverParts(hoverParts, hoverPartsContainer, this._onFinishedRendering); this.renderedHoverParts = this._renderHoverParts(hoverParts, hoverPartsContainer, this._onFinishedRendering);
@@ -315,8 +311,7 @@ class MarkdownRenderedHoverParts implements IRenderedHoverParts<MarkdownHover> {
const renderedMarkdownHover = renderMarkdown( const renderedMarkdownHover = renderMarkdown(
this._editor, this._editor,
markdownHover, markdownHover,
this._languageService, this._instantiationService,
this._openerService,
onFinishedRendering, onFinishedRendering,
); );
return renderedMarkdownHover; return renderedMarkdownHover;
@@ -476,8 +471,7 @@ export function renderMarkdownHovers(
context: IEditorHoverRenderContext, context: IEditorHoverRenderContext,
markdownHovers: MarkdownHover[], markdownHovers: MarkdownHover[],
editor: ICodeEditor, editor: ICodeEditor,
languageService: ILanguageService, instantiationService: IInstantiationService,
openerService: IOpenerService,
): IRenderedHoverParts<MarkdownHover> { ): IRenderedHoverParts<MarkdownHover> {
// Sort hover parts to keep them stable since they might come in async, out-of-order // Sort hover parts to keep them stable since they might come in async, out-of-order
@@ -487,8 +481,7 @@ export function renderMarkdownHovers(
const renderedHoverPart = renderMarkdown( const renderedHoverPart = renderMarkdown(
editor, editor,
markdownHover, markdownHover,
languageService, instantiationService,
openerService,
context.onContentsChanged, context.onContentsChanged,
); );
context.fragment.appendChild(renderedHoverPart.hoverElement); context.fragment.appendChild(renderedHoverPart.hoverElement);
@@ -500,8 +493,7 @@ export function renderMarkdownHovers(
function renderMarkdown( function renderMarkdown(
editor: ICodeEditor, editor: ICodeEditor,
markdownHover: MarkdownHover, markdownHover: MarkdownHover,
languageService: ILanguageService, instantiationService: IInstantiationService,
openerService: IOpenerService,
onFinishedRendering: () => void, onFinishedRendering: () => void,
): IRenderedHoverPart<MarkdownHover> { ): IRenderedHoverPart<MarkdownHover> {
const disposables = new DisposableStore(); const disposables = new DisposableStore();
@@ -515,7 +507,7 @@ function renderMarkdown(
} }
const markdownHoverElement = $('div.markdown-hover'); const markdownHoverElement = $('div.markdown-hover');
const hoverContentsElement = dom.append(markdownHoverElement, $('div.hover-contents')); const hoverContentsElement = dom.append(markdownHoverElement, $('div.hover-contents'));
const renderer = new MarkdownRenderer({ editor }, languageService, openerService); const renderer = instantiationService.createInstance(MarkdownRenderer, { editor });
const renderedContents = disposables.add(renderer.render(markdownString, { const renderedContents = disposables.add(renderer.render(markdownString, {
asyncRenderCallback: () => { asyncRenderCallback: () => {

View File

@@ -11,13 +11,11 @@ import { Position } from '../../../common/core/position.js';
import { IModelDecoration } from '../../../common/model.js'; import { IModelDecoration } from '../../../common/model.js';
import { ModelDecorationInjectedTextOptions } from '../../../common/model/textModel.js'; import { ModelDecorationInjectedTextOptions } from '../../../common/model/textModel.js';
import { HoverAnchor, HoverForeignElementAnchor, IEditorHoverParticipant } from '../../hover/browser/hoverTypes.js'; import { HoverAnchor, HoverForeignElementAnchor, IEditorHoverParticipant } from '../../hover/browser/hoverTypes.js';
import { ILanguageService } from '../../../common/languages/language.js';
import { ITextModelService } from '../../../common/services/resolverService.js'; import { ITextModelService } from '../../../common/services/resolverService.js';
import { getHoverProviderResultsAsAsyncIterable } from '../../hover/browser/getHover.js'; import { getHoverProviderResultsAsAsyncIterable } from '../../hover/browser/getHover.js';
import { MarkdownHover, MarkdownHoverParticipant } from '../../hover/browser/markdownHoverParticipant.js'; import { MarkdownHover, MarkdownHoverParticipant } from '../../hover/browser/markdownHoverParticipant.js';
import { RenderedInlayHintLabelPart, InlayHintsController } from './inlayHintsController.js'; import { RenderedInlayHintLabelPart, InlayHintsController } from './inlayHintsController.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js'; import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
import { ILanguageFeaturesService } from '../../../common/services/languageFeatures.js'; import { ILanguageFeaturesService } from '../../../common/services/languageFeatures.js';
import { EditorOption } from '../../../common/config/editorOptions.js'; import { EditorOption } from '../../../common/config/editorOptions.js';
import { localize } from '../../../../nls.js'; import { localize } from '../../../../nls.js';
@@ -28,6 +26,7 @@ import { IKeybindingService } from '../../../../platform/keybinding/common/keybi
import { IHoverService } from '../../../../platform/hover/browser/hover.js'; import { IHoverService } from '../../../../platform/hover/browser/hover.js';
import { ICommandService } from '../../../../platform/commands/common/commands.js'; import { ICommandService } from '../../../../platform/commands/common/commands.js';
import { HoverStartSource } from '../../hover/browser/hoverOperation.js'; import { HoverStartSource } from '../../hover/browser/hoverOperation.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
class InlayHintsHoverAnchor extends HoverForeignElementAnchor { class InlayHintsHoverAnchor extends HoverForeignElementAnchor {
constructor( constructor(
@@ -46,16 +45,15 @@ export class InlayHintsHover extends MarkdownHoverParticipant implements IEditor
constructor( constructor(
editor: ICodeEditor, editor: ICodeEditor,
@ILanguageService languageService: ILanguageService, @IInstantiationService instantiationService: IInstantiationService,
@IOpenerService openerService: IOpenerService,
@IKeybindingService keybindingService: IKeybindingService, @IKeybindingService keybindingService: IKeybindingService,
@IHoverService hoverService: IHoverService, @IHoverService hoverService: IHoverService,
@IConfigurationService configurationService: IConfigurationService, @IConfigurationService configurationService: IConfigurationService,
@ITextModelService private readonly _resolverService: ITextModelService, @ITextModelService private readonly _resolverService: ITextModelService,
@ILanguageFeaturesService languageFeaturesService: ILanguageFeaturesService, @ILanguageFeaturesService languageFeaturesService: ILanguageFeaturesService,
@ICommandService commandService: ICommandService @ICommandService commandService: ICommandService,
) { ) {
super(editor, languageService, openerService, configurationService, languageFeaturesService, keybindingService, hoverService, commandService); super(editor, instantiationService, configurationService, languageFeaturesService, keybindingService, hoverService, commandService);
} }
suggestHoverAnchor(mouseEvent: IEditorMouseEvent): HoverAnchor | null { suggestHoverAnchor(mouseEvent: IEditorMouseEvent): HoverAnchor | null {

View File

@@ -10,7 +10,6 @@ import { autorun, autorunWithStore, constObservable } from '../../../../../base/
import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from '../../../../browser/editorBrowser.js'; import { ICodeEditor, IEditorMouseEvent, MouseTargetType } from '../../../../browser/editorBrowser.js';
import { EditorOption } from '../../../../common/config/editorOptions.js'; import { EditorOption } from '../../../../common/config/editorOptions.js';
import { Range } from '../../../../common/core/range.js'; import { Range } from '../../../../common/core/range.js';
import { ILanguageService } from '../../../../common/languages/language.js';
import { IModelDecoration } from '../../../../common/model.js'; import { IModelDecoration } from '../../../../common/model.js';
import { HoverAnchor, HoverAnchorType, HoverForeignElementAnchor, IEditorHoverParticipant, IEditorHoverRenderContext, IHoverPart, IRenderedHoverPart, IRenderedHoverParts, RenderedHoverParts } from '../../../hover/browser/hoverTypes.js'; import { HoverAnchor, HoverAnchorType, HoverForeignElementAnchor, IEditorHoverParticipant, IEditorHoverRenderContext, IHoverPart, IRenderedHoverPart, IRenderedHoverParts, RenderedHoverParts } from '../../../hover/browser/hoverTypes.js';
import { InlineCompletionsController } from '../controller/inlineCompletionsController.js'; import { InlineCompletionsController } from '../controller/inlineCompletionsController.js';
@@ -19,7 +18,6 @@ import { MarkdownRenderer } from '../../../../browser/widget/markdownRenderer/br
import * as nls from '../../../../../nls.js'; import * as nls from '../../../../../nls.js';
import { IAccessibilityService } from '../../../../../platform/accessibility/common/accessibility.js'; import { IAccessibilityService } from '../../../../../platform/accessibility/common/accessibility.js';
import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js'; import { IInstantiationService } from '../../../../../platform/instantiation/common/instantiation.js';
import { IOpenerService } from '../../../../../platform/opener/common/opener.js';
import { ITelemetryService } from '../../../../../platform/telemetry/common/telemetry.js'; import { ITelemetryService } from '../../../../../platform/telemetry/common/telemetry.js';
import { GhostTextView } from '../view/ghostText/ghostTextView.js'; import { GhostTextView } from '../view/ghostText/ghostTextView.js';
@@ -45,8 +43,6 @@ export class InlineCompletionsHoverParticipant implements IEditorHoverParticipan
constructor( constructor(
private readonly _editor: ICodeEditor, private readonly _editor: ICodeEditor,
@ILanguageService private readonly _languageService: ILanguageService,
@IOpenerService private readonly _openerService: IOpenerService,
@IAccessibilityService private readonly accessibilityService: IAccessibilityService, @IAccessibilityService private readonly accessibilityService: IAccessibilityService,
@IInstantiationService private readonly _instantiationService: IInstantiationService, @IInstantiationService private readonly _instantiationService: IInstantiationService,
@ITelemetryService private readonly _telemetryService: ITelemetryService, @ITelemetryService private readonly _telemetryService: ITelemetryService,
@@ -154,7 +150,7 @@ export class InlineCompletionsHoverParticipant implements IEditorHoverParticipan
const $ = dom.$; const $ = dom.$;
const markdownHoverElement = $('div.hover-row.markdown-hover'); const markdownHoverElement = $('div.hover-row.markdown-hover');
const hoverContentsElement = dom.append(markdownHoverElement, $('div.hover-contents', { ['aria-live']: 'assertive' })); const hoverContentsElement = dom.append(markdownHoverElement, $('div.hover-contents', { ['aria-live']: 'assertive' }));
const renderer = new MarkdownRenderer({ editor: this._editor }, this._languageService, this._openerService); const renderer = this._instantiationService.createInstance(MarkdownRenderer, { editor: this._editor });
const render = (code: string) => { const render = (code: string) => {
const inlineSuggestionAvailable = nls.localize('inlineSuggestionFollows', "Suggestion:"); const inlineSuggestionAvailable = nls.localize('inlineSuggestionFollows', "Suggestion:");
const renderedContents = disposables.add(renderer.render(new MarkdownString().appendText(inlineSuggestionAvailable).appendCodeblock('text', code), { const renderedContents = disposables.add(renderer.render(new MarkdownString().appendText(inlineSuggestionAvailable).appendCodeblock('text', code), {

View File

@@ -17,16 +17,15 @@ import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentW
import { EditorOption } from '../../../common/config/editorOptions.js'; import { EditorOption } from '../../../common/config/editorOptions.js';
import { EDITOR_FONT_DEFAULTS } from '../../../common/config/fontInfo.js'; import { EDITOR_FONT_DEFAULTS } from '../../../common/config/fontInfo.js';
import * as languages from '../../../common/languages.js'; import * as languages from '../../../common/languages.js';
import { ILanguageService } from '../../../common/languages/language.js';
import { IMarkdownRenderResult, MarkdownRenderer } from '../../../browser/widget/markdownRenderer/browser/markdownRenderer.js'; import { IMarkdownRenderResult, MarkdownRenderer } from '../../../browser/widget/markdownRenderer/browser/markdownRenderer.js';
import { ParameterHintsModel } from './parameterHintsModel.js'; import { ParameterHintsModel } from './parameterHintsModel.js';
import { Context } from './provideSignatureHelp.js'; import { Context } from './provideSignatureHelp.js';
import * as nls from '../../../../nls.js'; import * as nls from '../../../../nls.js';
import { IContextKey, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js'; import { IContextKey, IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
import { listHighlightForeground, registerColor } from '../../../../platform/theme/common/colorRegistry.js'; import { listHighlightForeground, registerColor } from '../../../../platform/theme/common/colorRegistry.js';
import { registerIcon } from '../../../../platform/theme/common/iconRegistry.js'; import { registerIcon } from '../../../../platform/theme/common/iconRegistry.js';
import { ThemeIcon } from '../../../../base/common/themables.js'; import { ThemeIcon } from '../../../../base/common/themables.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
const $ = dom.$; const $ = dom.$;
@@ -60,12 +59,11 @@ export class ParameterHintsWidget extends Disposable implements IContentWidget {
private readonly editor: ICodeEditor, private readonly editor: ICodeEditor,
private readonly model: ParameterHintsModel, private readonly model: ParameterHintsModel,
@IContextKeyService contextKeyService: IContextKeyService, @IContextKeyService contextKeyService: IContextKeyService,
@IOpenerService openerService: IOpenerService, @IInstantiationService instantiationService: IInstantiationService
@ILanguageService languageService: ILanguageService
) { ) {
super(); super();
this.markdownRenderer = new MarkdownRenderer({ editor }, languageService, openerService); this.markdownRenderer = instantiationService.createInstance(MarkdownRenderer, { editor });
this.keyVisible = Context.Visible.bindTo(contextKeyService); this.keyVisible = Context.Visible.bindTo(contextKeyService);
this.keyMultipleSignatures = Context.MultipleSignatures.bindTo(contextKeyService); this.keyMultipleSignatures = Context.MultipleSignatures.bindTo(contextKeyService);

View File

@@ -20,14 +20,12 @@ import { IModelDecoration, IModelDeltaDecoration, ITextModel, TrackedRangeSticki
import { ModelDecorationOptions } from '../../../common/model/textModel.js'; import { ModelDecorationOptions } from '../../../common/model/textModel.js';
import { UnicodeHighlighterOptions, UnicodeHighlighterReason, UnicodeHighlighterReasonKind, UnicodeTextModelHighlighter } from '../../../common/services/unicodeTextModelHighlighter.js'; import { UnicodeHighlighterOptions, UnicodeHighlighterReason, UnicodeHighlighterReasonKind, UnicodeTextModelHighlighter } from '../../../common/services/unicodeTextModelHighlighter.js';
import { IEditorWorkerService, IUnicodeHighlightsResult } from '../../../common/services/editorWorker.js'; import { IEditorWorkerService, IUnicodeHighlightsResult } from '../../../common/services/editorWorker.js';
import { ILanguageService } from '../../../common/languages/language.js';
import { HoverAnchor, HoverAnchorType, HoverParticipantRegistry, IEditorHoverParticipant, IEditorHoverRenderContext, IHoverPart, IRenderedHoverParts } from '../../hover/browser/hoverTypes.js'; import { HoverAnchor, HoverAnchorType, HoverParticipantRegistry, IEditorHoverParticipant, IEditorHoverRenderContext, IHoverPart, IRenderedHoverParts } from '../../hover/browser/hoverTypes.js';
import { MarkdownHover, renderMarkdownHovers } from '../../hover/browser/markdownHoverParticipant.js'; import { MarkdownHover, renderMarkdownHovers } from '../../hover/browser/markdownHoverParticipant.js';
import { BannerController } from './bannerController.js'; import { BannerController } from './bannerController.js';
import * as nls from '../../../../nls.js'; import * as nls from '../../../../nls.js';
import { ConfigurationTarget, IConfigurationService } from '../../../../platform/configuration/common/configuration.js'; import { ConfigurationTarget, IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js'; import { IInstantiationService } from '../../../../platform/instantiation/common/instantiation.js';
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
import { IQuickInputService, IQuickPickItem } from '../../../../platform/quickinput/common/quickInput.js'; import { IQuickInputService, IQuickPickItem } from '../../../../platform/quickinput/common/quickInput.js';
import { registerIcon } from '../../../../platform/theme/common/iconRegistry.js'; import { registerIcon } from '../../../../platform/theme/common/iconRegistry.js';
import { IWorkspaceTrustManagementService } from '../../../../platform/workspace/common/workspaceTrust.js'; import { IWorkspaceTrustManagementService } from '../../../../platform/workspace/common/workspaceTrust.js';
@@ -419,10 +417,8 @@ export class UnicodeHighlighterHoverParticipant implements IEditorHoverParticipa
constructor( constructor(
private readonly _editor: ICodeEditor, private readonly _editor: ICodeEditor,
@ILanguageService private readonly _languageService: ILanguageService, @IInstantiationService private readonly _instantiationService: IInstantiationService,
@IOpenerService private readonly _openerService: IOpenerService, ) { }
) {
}
computeSync(anchor: HoverAnchor, lineDecorations: IModelDecoration[]): MarkdownHover[] { computeSync(anchor: HoverAnchor, lineDecorations: IModelDecoration[]): MarkdownHover[] {
if (!this._editor.hasModel() || anchor.type !== HoverAnchorType.Range) { if (!this._editor.hasModel() || anchor.type !== HoverAnchorType.Range) {
@@ -513,7 +509,7 @@ export class UnicodeHighlighterHoverParticipant implements IEditorHoverParticipa
} }
public renderHoverParts(context: IEditorHoverRenderContext, hoverParts: MarkdownHover[]): IRenderedHoverParts<MarkdownHover> { public renderHoverParts(context: IEditorHoverRenderContext, hoverParts: MarkdownHover[]): IRenderedHoverParts<MarkdownHover> {
return renderMarkdownHovers(context, hoverParts, this._editor, this._languageService, this._openerService); return renderMarkdownHovers(context, hoverParts, this._editor, this._instantiationService);
} }
public getAccessibleContent(hoverPart: MarkdownHover): string { public getAccessibleContent(hoverPart: MarkdownHover): string {

View File

@@ -12,6 +12,7 @@ import { URI } from '../../../../base/common/uri.js';
import { IMarkdownRendererOptions, IMarkdownRenderResult, MarkdownRenderer } from '../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js'; import { IMarkdownRendererOptions, IMarkdownRenderResult, MarkdownRenderer } from '../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
import { ILanguageService } from '../../../../editor/common/languages/language.js'; import { ILanguageService } from '../../../../editor/common/languages/language.js';
import { ICommandService } from '../../../../platform/commands/common/commands.js'; import { ICommandService } from '../../../../platform/commands/common/commands.js';
import { IConfigurationService } from '../../../../platform/configuration/common/configuration.js';
import { IFileService } from '../../../../platform/files/common/files.js'; import { IFileService } from '../../../../platform/files/common/files.js';
import { IHoverService } from '../../../../platform/hover/browser/hover.js'; import { IHoverService } from '../../../../platform/hover/browser/hover.js';
import { IOpenerService } from '../../../../platform/opener/common/opener.js'; import { IOpenerService } from '../../../../platform/opener/common/opener.js';
@@ -68,11 +69,12 @@ export class ChatMarkdownRenderer extends MarkdownRenderer {
options: IMarkdownRendererOptions | undefined, options: IMarkdownRendererOptions | undefined,
@ILanguageService languageService: ILanguageService, @ILanguageService languageService: ILanguageService,
@IOpenerService openerService: IOpenerService, @IOpenerService openerService: IOpenerService,
@IConfigurationService configurationService: IConfigurationService,
@IHoverService private readonly hoverService: IHoverService, @IHoverService private readonly hoverService: IHoverService,
@IFileService private readonly fileService: IFileService, @IFileService private readonly fileService: IFileService,
@ICommandService private readonly commandService: ICommandService, @ICommandService private readonly commandService: ICommandService,
) { ) {
super(options ?? {}, languageService, openerService); super(options ?? {}, configurationService, languageService, openerService);
} }
override render(markdown: IMarkdownString, options?: MarkdownRenderOptions, outElement?: HTMLElement): IMarkdownRenderResult { override render(markdown: IMarkdownString, options?: MarkdownRenderOptions, outElement?: HTMLElement): IMarkdownRenderResult {

View File

@@ -16,8 +16,6 @@ import { IInstantiationService } from '../../../../platform/instantiation/common
import { URI } from '../../../../base/common/uri.js'; import { URI } from '../../../../base/common/uri.js';
import { ICommentThreadWidget } from '../common/commentThreadWidget.js'; import { ICommentThreadWidget } from '../common/commentThreadWidget.js';
import { IMarkdownRendererOptions, MarkdownRenderer } from '../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js'; import { IMarkdownRendererOptions, MarkdownRenderer } from '../../../../editor/browser/widget/markdownRenderer/browser/markdownRenderer.js';
import { IOpenerService } from '../../../../platform/opener/common/opener.js';
import { ILanguageService } from '../../../../editor/common/languages/language.js';
import { ICellRange } from '../../notebook/common/notebookRange.js'; import { ICellRange } from '../../notebook/common/notebookRange.js';
import { IRange } from '../../../../editor/common/core/range.js'; import { IRange } from '../../../../editor/common/core/range.js';
import { LayoutableEditor } from './simpleCommentEditor.js'; import { LayoutableEditor } from './simpleCommentEditor.js';
@@ -52,8 +50,6 @@ export class CommentThreadBody<T extends IRange | ICellRange = IRange> extends D
private _scopedInstatiationService: IInstantiationService, private _scopedInstatiationService: IInstantiationService,
private _parentCommentThreadWidget: ICommentThreadWidget, private _parentCommentThreadWidget: ICommentThreadWidget,
@ICommentService private commentService: ICommentService, @ICommentService private commentService: ICommentService,
@IOpenerService private openerService: IOpenerService,
@ILanguageService private languageService: ILanguageService,
) { ) {
super(); super();
@@ -62,7 +58,7 @@ export class CommentThreadBody<T extends IRange | ICellRange = IRange> extends D
this.commentService.setActiveEditingCommentThread(this._commentThread); this.commentService.setActiveEditingCommentThread(this._commentThread);
})); }));
this._markdownRenderer = new MarkdownRenderer(this._options, this.languageService, this.openerService); this._markdownRenderer = this._scopedInstatiationService.createInstance(MarkdownRenderer, this._options);
} }
focus(commentUniqueId?: number) { focus(commentUniqueId?: number) {

View File

@@ -18,8 +18,7 @@ import { IColorTheme, IThemeService } from '../../../../platform/theme/common/th
import { CommentGlyphWidget } from './commentGlyphWidget.js'; import { CommentGlyphWidget } from './commentGlyphWidget.js';
import { ICommentService } from './commentService.js'; import { ICommentService } from './commentService.js';
import { ICommentThreadWidget } from '../common/commentThreadWidget.js'; import { ICommentThreadWidget } from '../common/commentThreadWidget.js';
import { EditorOption, IEditorOptions } from '../../../../editor/common/config/editorOptions.js'; import { EditorOption } from '../../../../editor/common/config/editorOptions.js';
import { EDITOR_FONT_DEFAULTS } from '../../../../editor/common/config/fontInfo.js';
import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js'; import { ServiceCollection } from '../../../../platform/instantiation/common/serviceCollection.js';
import { CommentThreadWidget } from './commentThreadWidget.js'; import { CommentThreadWidget } from './commentThreadWidget.js';
import { commentThreadStateBackgroundColorVar, commentThreadStateColorVar, getCommentThreadStateBorderColor } from './commentColors.js'; import { commentThreadStateBackgroundColorVar, commentThreadStateColorVar, getCommentThreadStateBorderColor } from './commentColors.js';
@@ -272,7 +271,7 @@ export class ReviewZoneWidget extends ZoneWidget implements ICommentThreadWidget
this._commentThread, this._commentThread,
this._pendingComment, this._pendingComment,
this._pendingEdits, this._pendingEdits,
{ editor: this.editor, codeBlockFontSize: '', codeBlockFontFamily: this.configurationService.getValue<IEditorOptions>('editor').fontFamily || EDITOR_FONT_DEFAULTS.fontFamily }, { editor: this.editor, codeBlockFontSize: '' },
this._commentOptions, this._commentOptions,
{ {
actionRunner: async () => { actionRunner: async () => {

View File

@@ -5,10 +5,7 @@
import { coalesce } from '../../../../../../base/common/arrays.js'; import { coalesce } from '../../../../../../base/common/arrays.js';
import { DisposableMap, DisposableStore } from '../../../../../../base/common/lifecycle.js'; import { DisposableMap, DisposableStore } from '../../../../../../base/common/lifecycle.js';
import { IEditorOptions } from '../../../../../../editor/common/config/editorOptions.js';
import { EDITOR_FONT_DEFAULTS } from '../../../../../../editor/common/config/fontInfo.js';
import * as languages from '../../../../../../editor/common/languages.js'; import * as languages from '../../../../../../editor/common/languages.js';
import { IConfigurationService } from '../../../../../../platform/configuration/common/configuration.js';
import { IContextKeyService } from '../../../../../../platform/contextkey/common/contextkey.js'; import { IContextKeyService } from '../../../../../../platform/contextkey/common/contextkey.js';
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js'; import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
import { IThemeService } from '../../../../../../platform/theme/common/themeService.js'; import { IThemeService } from '../../../../../../platform/theme/common/themeService.js';
@@ -29,7 +26,6 @@ export class CellComments extends CellContentPart {
@IContextKeyService private readonly contextKeyService: IContextKeyService, @IContextKeyService private readonly contextKeyService: IContextKeyService,
@IThemeService private readonly themeService: IThemeService, @IThemeService private readonly themeService: IThemeService,
@ICommentService private readonly commentService: ICommentService, @ICommentService private readonly commentService: ICommentService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IInstantiationService private readonly instantiationService: IInstantiationService @IInstantiationService private readonly instantiationService: IInstantiationService
) { ) {
super(); super();
@@ -65,9 +61,7 @@ export class CellComments extends CellContentPart {
commentThread, commentThread,
undefined, undefined,
undefined, undefined,
{ {},
codeBlockFontFamily: this.configurationService.getValue<IEditorOptions>('editor').fontFamily || EDITOR_FONT_DEFAULTS.fontFamily
},
undefined, undefined,
{ {
actionRunner: () => { actionRunner: () => {