|
4 | 4 | *--------------------------------------------------------------------------------------------*/
|
5 | 5 |
|
6 | 6 | import * as dom from 'vs/base/browser/dom';
|
7 |
| -import { asArray } from 'vs/base/common/arrays'; |
8 |
| -import { IMarkdownString, isEmptyMarkdownString } from 'vs/base/common/htmlContent'; |
9 | 7 | import { Disposable, DisposableStore } from 'vs/base/common/lifecycle';
|
10 | 8 | import { MarkdownRenderer } from 'vs/editor/browser/widget/markdownRenderer/browser/markdownRenderer';
|
11 | 9 | import { ICodeEditor, IEditorMouseEvent, IOverlayWidget, IOverlayWidgetPosition, MouseTargetType } from 'vs/editor/browser/editorBrowser';
|
12 | 10 | import { ConfigurationChangedEvent, EditorOption } from 'vs/editor/common/config/editorOptions';
|
13 | 11 | import { ILanguageService } from 'vs/editor/common/languages/language';
|
14 |
| -import { HoverOperation, HoverStartMode, IHoverComputer } from 'vs/editor/contrib/hover/browser/hoverOperation'; |
| 12 | +import { HoverOperation, HoverStartMode } from 'vs/editor/contrib/hover/browser/hoverOperation'; |
15 | 13 | import { IOpenerService } from 'vs/platform/opener/common/opener';
|
16 | 14 | import { HoverWidget } from 'vs/base/browser/ui/hover/hoverWidget';
|
17 |
| -import { GlyphMarginLane } from 'vs/editor/common/model'; |
18 | 15 | import { IHoverWidget } from 'vs/editor/contrib/hover/browser/hoverTypes';
|
| 16 | +import { IHoverMessage, LaneOrLineNumber, MarginHoverComputer } from 'vs/editor/contrib/hover/browser/marginHoverComputer'; |
19 | 17 |
|
20 | 18 | const $ = dom.$;
|
21 | 19 |
|
22 |
| -export interface IHoverMessage { |
23 |
| - value: IMarkdownString; |
24 |
| -} |
25 |
| - |
26 |
| -type LaneOrLineNumber = GlyphMarginLane | 'lineNo'; |
27 |
| - |
28 | 20 | export class MarginHoverWidget extends Disposable implements IOverlayWidget, IHoverWidget {
|
29 | 21 |
|
30 | 22 | public static readonly ID = 'editor.contrib.modesGlyphHoverWidget';
|
@@ -190,63 +182,3 @@ export class MarginHoverWidget extends Disposable implements IOverlayWidget, IHo
|
190 | 182 | this._hover.containerDomNode.style.top = `${Math.max(Math.round(top), 0)}px`;
|
191 | 183 | }
|
192 | 184 | }
|
193 |
| - |
194 |
| -class MarginHoverComputer implements IHoverComputer<IHoverMessage> { |
195 |
| - |
196 |
| - private _lineNumber: number = -1; |
197 |
| - private _laneOrLine: LaneOrLineNumber = GlyphMarginLane.Center; |
198 |
| - |
199 |
| - public get lineNumber(): number { |
200 |
| - return this._lineNumber; |
201 |
| - } |
202 |
| - |
203 |
| - public set lineNumber(value: number) { |
204 |
| - this._lineNumber = value; |
205 |
| - } |
206 |
| - |
207 |
| - public get lane(): LaneOrLineNumber { |
208 |
| - return this._laneOrLine; |
209 |
| - } |
210 |
| - |
211 |
| - public set lane(value: LaneOrLineNumber) { |
212 |
| - this._laneOrLine = value; |
213 |
| - } |
214 |
| - |
215 |
| - constructor( |
216 |
| - private readonly _editor: ICodeEditor |
217 |
| - ) { |
218 |
| - } |
219 |
| - |
220 |
| - public computeSync(): IHoverMessage[] { |
221 |
| - |
222 |
| - const toHoverMessage = (contents: IMarkdownString): IHoverMessage => { |
223 |
| - return { |
224 |
| - value: contents |
225 |
| - }; |
226 |
| - }; |
227 |
| - |
228 |
| - const lineDecorations = this._editor.getLineDecorations(this._lineNumber); |
229 |
| - |
230 |
| - const result: IHoverMessage[] = []; |
231 |
| - const isLineHover = this._laneOrLine === 'lineNo'; |
232 |
| - if (!lineDecorations) { |
233 |
| - return result; |
234 |
| - } |
235 |
| - |
236 |
| - for (const d of lineDecorations) { |
237 |
| - const lane = d.options.glyphMargin?.position ?? GlyphMarginLane.Center; |
238 |
| - if (!isLineHover && lane !== this._laneOrLine) { |
239 |
| - continue; |
240 |
| - } |
241 |
| - |
242 |
| - const hoverMessage = isLineHover ? d.options.lineNumberHoverMessage : d.options.glyphMarginHoverMessage; |
243 |
| - if (!hoverMessage || isEmptyMarkdownString(hoverMessage)) { |
244 |
| - continue; |
245 |
| - } |
246 |
| - |
247 |
| - result.push(...asArray(hoverMessage).map(toHoverMessage)); |
248 |
| - } |
249 |
| - |
250 |
| - return result; |
251 |
| - } |
252 |
| -} |
0 commit comments