mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 5e80bf449c995aa32a59254c0ff845d37da11b70 (#9317)
This commit is contained in:
@@ -18,9 +18,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
]);
|
||||
|
||||
assert.deepEqual(result, [
|
||||
new DecorationSegment(0, 1, 'c1'),
|
||||
new DecorationSegment(2, 2, 'c2 c1'),
|
||||
new DecorationSegment(3, 9, 'c1'),
|
||||
new DecorationSegment(0, 1, 'c1', 0),
|
||||
new DecorationSegment(2, 2, 'c2 c1', 0),
|
||||
new DecorationSegment(3, 9, 'c1', 0),
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -32,8 +32,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
]);
|
||||
|
||||
assert.deepEqual(result, [
|
||||
new DecorationSegment(14, 18, 'mtkw'),
|
||||
new DecorationSegment(19, 19, 'mtkw inline-folded')
|
||||
new DecorationSegment(14, 18, 'mtkw', 0),
|
||||
new DecorationSegment(19, 19, 'mtkw inline-folded', 0)
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -66,24 +66,24 @@ suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
new LineDecoration(1, 2, 'c1', InlineDecorationType.Regular),
|
||||
new LineDecoration(3, 4, 'c2', InlineDecorationType.Regular)
|
||||
]), [
|
||||
new DecorationSegment(0, 0, 'c1'),
|
||||
new DecorationSegment(2, 2, 'c2')
|
||||
new DecorationSegment(0, 0, 'c1', 0),
|
||||
new DecorationSegment(2, 2, 'c2', 0)
|
||||
]);
|
||||
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize('abcabcabcabcabcabcabcabcabcabc', [
|
||||
new LineDecoration(1, 3, 'c1', InlineDecorationType.Regular),
|
||||
new LineDecoration(3, 4, 'c2', InlineDecorationType.Regular)
|
||||
]), [
|
||||
new DecorationSegment(0, 1, 'c1'),
|
||||
new DecorationSegment(2, 2, 'c2')
|
||||
new DecorationSegment(0, 1, 'c1', 0),
|
||||
new DecorationSegment(2, 2, 'c2', 0)
|
||||
]);
|
||||
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize('abcabcabcabcabcabcabcabcabcabc', [
|
||||
new LineDecoration(1, 4, 'c1', InlineDecorationType.Regular),
|
||||
new LineDecoration(3, 4, 'c2', InlineDecorationType.Regular)
|
||||
]), [
|
||||
new DecorationSegment(0, 1, 'c1'),
|
||||
new DecorationSegment(2, 2, 'c1 c2')
|
||||
new DecorationSegment(0, 1, 'c1', 0),
|
||||
new DecorationSegment(2, 2, 'c1 c2', 0)
|
||||
]);
|
||||
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize('abcabcabcabcabcabcabcabcabcabc', [
|
||||
@@ -91,8 +91,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
new LineDecoration(1, 4, 'c1*', InlineDecorationType.Regular),
|
||||
new LineDecoration(3, 4, 'c2', InlineDecorationType.Regular)
|
||||
]), [
|
||||
new DecorationSegment(0, 1, 'c1 c1*'),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c2')
|
||||
new DecorationSegment(0, 1, 'c1 c1*', 0),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c2', 0)
|
||||
]);
|
||||
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize('abcabcabcabcabcabcabcabcabcabc', [
|
||||
@@ -101,8 +101,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
new LineDecoration(1, 4, 'c1**', InlineDecorationType.Regular),
|
||||
new LineDecoration(3, 4, 'c2', InlineDecorationType.Regular)
|
||||
]), [
|
||||
new DecorationSegment(0, 1, 'c1 c1* c1**'),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c1** c2')
|
||||
new DecorationSegment(0, 1, 'c1 c1* c1**', 0),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c1** c2', 0)
|
||||
]);
|
||||
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize('abcabcabcabcabcabcabcabcabcabc', [
|
||||
@@ -112,8 +112,8 @@ suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
new LineDecoration(3, 4, 'c2', InlineDecorationType.Regular),
|
||||
new LineDecoration(3, 4, 'c2*', InlineDecorationType.Regular)
|
||||
]), [
|
||||
new DecorationSegment(0, 1, 'c1 c1* c1**'),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*')
|
||||
new DecorationSegment(0, 1, 'c1 c1* c1**', 0),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*', 0)
|
||||
]);
|
||||
|
||||
assert.deepEqual(LineDecorationsNormalizer.normalize('abcabcabcabcabcabcabcabcabcabc', [
|
||||
@@ -123,9 +123,9 @@ suite('Editor ViewLayout - ViewLineParts', () => {
|
||||
new LineDecoration(3, 4, 'c2', InlineDecorationType.Regular),
|
||||
new LineDecoration(3, 5, 'c2*', InlineDecorationType.Regular)
|
||||
]), [
|
||||
new DecorationSegment(0, 1, 'c1 c1* c1**'),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*'),
|
||||
new DecorationSegment(3, 3, 'c2*')
|
||||
new DecorationSegment(0, 1, 'c1 c1* c1**', 0),
|
||||
new DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*', 0),
|
||||
new DecorationSegment(3, 3, 'c2*', 0)
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -388,6 +388,66 @@ suite('viewLineRenderer.renderLine', () => {
|
||||
assertCharacterMapping(_actual.characterMapping, expectedOffsetsArr, [12, 12, 24, 1, 21, 2, 1, 20, 1, 1]);
|
||||
});
|
||||
|
||||
test('issue #91178: after decoration type shown before cursor', () => {
|
||||
const lineText = '//just a comment';
|
||||
const lineParts = createViewLineTokens([
|
||||
createPart(16, 1)
|
||||
]);
|
||||
const expectedOutput = [
|
||||
'<span class="mtk1">//just\u00a0a\u00a0com</span>',
|
||||
'<span class="mtk1 dec2"></span>',
|
||||
'<span class="mtk1 dec1"></span>',
|
||||
'<span class="mtk1">ment</span>',
|
||||
].join('');
|
||||
|
||||
const expectedCharacterMapping = new CharacterMapping(17, 4);
|
||||
expectedCharacterMapping.setPartData(0, 0, 0, 0);
|
||||
expectedCharacterMapping.setPartData(1, 0, 1, 0);
|
||||
expectedCharacterMapping.setPartData(2, 0, 2, 0);
|
||||
expectedCharacterMapping.setPartData(3, 0, 3, 0);
|
||||
expectedCharacterMapping.setPartData(4, 0, 4, 0);
|
||||
expectedCharacterMapping.setPartData(5, 0, 5, 0);
|
||||
expectedCharacterMapping.setPartData(6, 0, 6, 0);
|
||||
expectedCharacterMapping.setPartData(7, 0, 7, 0);
|
||||
expectedCharacterMapping.setPartData(8, 0, 8, 0);
|
||||
expectedCharacterMapping.setPartData(9, 0, 9, 0);
|
||||
expectedCharacterMapping.setPartData(10, 0, 10, 0);
|
||||
expectedCharacterMapping.setPartData(11, 0, 11, 0);
|
||||
expectedCharacterMapping.setPartData(12, 2, 0, 12);
|
||||
expectedCharacterMapping.setPartData(13, 3, 1, 12);
|
||||
expectedCharacterMapping.setPartData(14, 3, 2, 12);
|
||||
expectedCharacterMapping.setPartData(15, 3, 3, 12);
|
||||
expectedCharacterMapping.setPartData(16, 3, 4, 12);
|
||||
|
||||
const actual = renderViewLine(new RenderLineInput(
|
||||
true,
|
||||
false,
|
||||
lineText,
|
||||
false,
|
||||
true,
|
||||
false,
|
||||
0,
|
||||
lineParts,
|
||||
[
|
||||
new LineDecoration(13, 13, 'dec1', InlineDecorationType.After),
|
||||
new LineDecoration(13, 13, 'dec2', InlineDecorationType.Before),
|
||||
],
|
||||
4,
|
||||
0,
|
||||
10,
|
||||
10,
|
||||
10,
|
||||
-1,
|
||||
'none',
|
||||
false,
|
||||
false,
|
||||
null
|
||||
));
|
||||
|
||||
assert.equal(actual.html, '<span>' + expectedOutput + '</span>');
|
||||
assertCharacterMapping2(actual.characterMapping, expectedCharacterMapping);
|
||||
});
|
||||
|
||||
test('issue Microsoft/monaco-editor#280: Improved source code rendering for RTL languages', () => {
|
||||
let lineText = 'var קודמות = \"מיותר קודמות צ\'ט של, אם לשון העברית שינויים ויש, אם\";';
|
||||
|
||||
@@ -693,6 +753,33 @@ suite('viewLineRenderer.renderLine', () => {
|
||||
assert.equal(_actual.html, '<span>' + expectedOutput + '</span>');
|
||||
});
|
||||
|
||||
interface ICharMappingData {
|
||||
charOffset: number;
|
||||
partIndex: number;
|
||||
charIndex: number;
|
||||
}
|
||||
|
||||
function decodeCharacterMapping(source: CharacterMapping) {
|
||||
const mapping: ICharMappingData[] = [];
|
||||
for (let charOffset = 0; charOffset < source.length; charOffset++) {
|
||||
const partData = source.charOffsetToPartData(charOffset);
|
||||
const partIndex = CharacterMapping.getPartIndex(partData);
|
||||
const charIndex = CharacterMapping.getCharIndex(partData);
|
||||
mapping.push({ charOffset, partIndex, charIndex });
|
||||
}
|
||||
const absoluteOffsets: number[] = [];
|
||||
for (const absoluteOffset of source.getAbsoluteOffsets()) {
|
||||
absoluteOffsets.push(absoluteOffset);
|
||||
}
|
||||
return { mapping, absoluteOffsets };
|
||||
}
|
||||
|
||||
function assertCharacterMapping2(actual: CharacterMapping, expected: CharacterMapping): void {
|
||||
const _actual = decodeCharacterMapping(actual);
|
||||
const _expected = decodeCharacterMapping(expected);
|
||||
assert.deepEqual(_actual, _expected);
|
||||
}
|
||||
|
||||
function assertCharacterMapping(actual: CharacterMapping, expectedCharPartOffsets: number[][], expectedPartLengths: number[]): void {
|
||||
|
||||
assertCharPartOffsets(actual, expectedCharPartOffsets);
|
||||
|
||||
Reference in New Issue
Block a user