Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/editor/contrib/hover/test/browser/contentHover.test.ts
5313 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import assert from 'assert';
7
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../../base/test/common/utils.js';
8
import { Position } from '../../../../common/core/position.js';
9
import { Range } from '../../../../common/core/range.js';
10
import { RenderedContentHover } from '../../browser/contentHoverRendered.js';
11
import { IHoverPart } from '../../browser/hoverTypes.js';
12
import { TestCodeEditorInstantiationOptions, withTestCodeEditor } from '../../../../test/browser/testCodeEditor.js';
13
14
suite('Content Hover', () => {
15
16
ensureNoDisposablesAreLeakedInTestSuite();
17
18
test('issue #151235: Gitlens hover shows up in the wrong place', () => {
19
const text = 'just some text';
20
withTestCodeEditor(text, {}, (editor) => {
21
const actual = RenderedContentHover.computeHoverPositions(
22
editor,
23
new Range(5, 5, 5, 5),
24
[<IHoverPart>{ range: new Range(4, 1, 5, 6) }]
25
);
26
assert.deepStrictEqual(
27
actual,
28
{
29
showAtPosition: new Position(5, 5),
30
showAtSecondaryPosition: new Position(5, 5)
31
}
32
);
33
});
34
});
35
36
test('issue #95328: Hover placement with word-wrap', () => {
37
const text = 'just some text';
38
const opts: TestCodeEditorInstantiationOptions = { wordWrap: 'wordWrapColumn', wordWrapColumn: 6 };
39
withTestCodeEditor(text, opts, (editor) => {
40
const actual = RenderedContentHover.computeHoverPositions(
41
editor,
42
new Range(1, 8, 1, 8),
43
[<IHoverPart>{ range: new Range(1, 1, 1, 15) }]
44
);
45
assert.deepStrictEqual(
46
actual,
47
{
48
showAtPosition: new Position(1, 8),
49
showAtSecondaryPosition: new Position(1, 6)
50
}
51
);
52
});
53
});
54
});
55
56