提交 772defa0 编写于 作者: S Sandeep Somavarapu

#69388 Let hovers create the marker renderers

上级 2e173fab
......@@ -19,7 +19,6 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import { HoverStartMode } from 'vs/editor/contrib/hover/hoverOperation';
import { ModesContentHoverWidget } from 'vs/editor/contrib/hover/modesContentHover';
import { ModesGlyphHoverWidget } from 'vs/editor/contrib/hover/modesGlyphHover';
import { MarkdownRenderer } from 'vs/editor/contrib/markdown/markdownRenderer';
import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { editorHoverBackground, editorHoverBorder, editorHoverHighlight, textCodeBlockBackground, textLinkForeground, editorHoverStatusBarBackground } from 'vs/platform/theme/common/colorRegistry';
......@@ -214,9 +213,8 @@ export class ModesHoverController implements IEditorContribution {
}
private _createHoverWidget() {
const renderer = new MarkdownRenderer(this._editor, this._modeService, this._openerService);
this._contentWidget = new ModesContentHoverWidget(this._editor, renderer, this._markerDecorationsService, this._themeService, this._keybindingService, this._contextMenuService, this._bulkEditService, this._commandService, this._openerService);
this._glyphWidget = new ModesGlyphHoverWidget(this._editor, renderer);
this._contentWidget = new ModesContentHoverWidget(this._editor, this._markerDecorationsService, this._themeService, this._keybindingService, this._contextMenuService, this._bulkEditService, this._commandService, this._modeService, this._openerService);
this._glyphWidget = new ModesGlyphHoverWidget(this._editor, this._modeService, this._openerService);
}
public showContentHover(range: Range, mode: HoverStartMode, focus: boolean): void {
......
......@@ -39,6 +39,7 @@ import { getCodeActions } from 'vs/editor/contrib/codeAction/codeAction';
import { applyCodeAction, QuickFixAction } from 'vs/editor/contrib/codeAction/codeActionCommands';
import { Action } from 'vs/base/common/actions';
import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger';
import { IModeService } from 'vs/editor/common/services/modeService';
const $ = dom.$;
......@@ -205,7 +206,6 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
private _hoverOperation: HoverOperation<HoverPart[]>;
private _highlightDecorations: string[];
private _isChangingDecorations: boolean;
private _markdownRenderer: MarkdownRenderer;
private _shouldFocus: boolean;
private _colorPicker: ColorPickerWidget | null;
......@@ -213,13 +213,13 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
constructor(
editor: ICodeEditor,
markdownRenderer: MarkdownRenderer,
markerDecorationsService: IMarkerDecorationsService,
private readonly _themeService: IThemeService,
private readonly _keybindingService: IKeybindingService,
private readonly _contextMenuService: IContextMenuService,
private readonly _bulkEditService: IBulkEditService,
private readonly _commandService: ICommandService,
private readonly _modeService: IModeService,
private readonly _openerService: IOpenerService | null = NullOpenerService,
) {
super(ModesContentHoverWidget.ID, editor);
......@@ -230,9 +230,6 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
this._highlightDecorations = [];
this._isChangingDecorations = false;
this._markdownRenderer = markdownRenderer;
this._register(markdownRenderer.onDidRenderCodeBlock(this.onContentsChange, this));
this._hoverOperation = new HoverOperation(
this._computer,
result => this._withResult(result, true),
......@@ -357,7 +354,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
let isEmptyHoverContent = true;
let containColorPicker = false;
let markdownDisposeable: IDisposable;
let markdownDisposeables: IDisposable[] = [];
const markerMessages: MarkerHover[] = [];
messages.forEach((msg) => {
if (!msg.range) {
......@@ -448,7 +445,7 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
this.updateContents(fragment);
this._colorPicker.layout();
this.renderDisposable = combinedDisposable([colorListener, colorChangeListener, widget, markdownDisposeable]);
this.renderDisposable = combinedDisposable([colorListener, colorChangeListener, widget, ...markdownDisposeables]);
});
} else {
if (msg instanceof MarkerHover) {
......@@ -458,9 +455,14 @@ export class ModesContentHoverWidget extends ContentHoverWidget {
msg.contents
.filter(contents => !isEmptyMarkdownString(contents))
.forEach(contents => {
const renderedContents = this._markdownRenderer.render(contents);
markdownDisposeable = renderedContents;
fragment.appendChild($('div.hover-row.hover-contents', undefined, renderedContents.element));
const markdownHoverElement = $('div.hover-row.markdown-hover');
const hoverContentsElement = dom.append(markdownHoverElement, $('div.hover-contents'));
const renderer = new MarkdownRenderer(this._editor, this._modeService, this._openerService);
markdownDisposeables.push(renderer.onDidRenderCodeBlock(() => this.onContentsChange()));
const renderedContents = renderer.render(contents);
hoverContentsElement.appendChild(renderedContents.element);
fragment.appendChild(markdownHoverElement);
markdownDisposeables.push(renderedContents);
isEmptyHoverContent = false;
});
}
......
......@@ -10,6 +10,8 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { HoverOperation, HoverStartMode, IHoverComputer } from 'vs/editor/contrib/hover/hoverOperation';
import { GlyphHoverWidget } from 'vs/editor/contrib/hover/hoverWidgets';
import { MarkdownRenderer } from 'vs/editor/contrib/markdown/markdownRenderer';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IOpenerService, NullOpenerService } from 'vs/platform/opener/common/opener';
export interface IHoverMessage {
value: IMarkdownString;
......@@ -94,12 +96,16 @@ export class ModesGlyphHoverWidget extends GlyphHoverWidget {
private _hoverOperation: HoverOperation<IHoverMessage[]>;
private _renderDisposeables: IDisposable[];
constructor(editor: ICodeEditor, markdownRenderer: MarkdownRenderer) {
constructor(
editor: ICodeEditor,
modeService: IModeService,
openerService: IOpenerService | null = NullOpenerService,
) {
super(ModesGlyphHoverWidget.ID, editor);
this._lastLineNumber = -1;
this._markdownRenderer = markdownRenderer;
this._markdownRenderer = new MarkdownRenderer(this._editor, modeService, openerService);
this._computer = new MarginComputer(this._editor);
this._hoverOperation = new HoverOperation(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册