提交 cc88aa58 编写于 作者: A Alex Dima

Fixes #3661: wrapped inline decorations respect view model's min column

上级 42f6a503
......@@ -74,6 +74,7 @@ export class ViewLine implements IVisibleLineData {
// Compute new line parts only if there is some evidence that something might have changed
newLineParts = createLineParts(
lineNumber,
this._context.model.getLineMinColumn(lineNumber),
this._context.model.getLineContent(lineNumber),
this._context.model.getLineTokens(lineNumber),
inlineDecorations,
......
......@@ -1782,7 +1782,7 @@ class InlineViewZonesComputer extends ViewZonesComputer {
}
};
parts = createLineParts(lineNumber, lineContent, lineTokens, decorations, config.renderWhitespace);
parts = createLineParts(lineNumber, 1, lineContent, lineTokens, decorations, config.renderWhitespace);
var r = renderLine({
lineContent: lineContent,
......
......@@ -22,7 +22,7 @@ function cmpLineDecorations(a:ILineDecoration, b:ILineDecoration): number {
return Range.compareRangesUsingStarts(a.range, b.range);
}
export function createLineParts(lineNumber:number, lineContent:string, lineTokens:IViewLineTokens, rawLineDecorations:ILineDecoration[], renderWhitespace:boolean): ILineParts {
export function createLineParts(lineNumber:number, minLineColumn:number, lineContent:string, lineTokens:IViewLineTokens, rawLineDecorations:ILineDecoration[], renderWhitespace:boolean): ILineParts {
if (renderWhitespace) {
let oldLength = rawLineDecorations.length;
rawLineDecorations = insertWhitespace(lineNumber, lineContent, lineTokens.getFauxIndentLength(), rawLineDecorations);
......@@ -32,7 +32,7 @@ export function createLineParts(lineNumber:number, lineContent:string, lineToken
}
if (rawLineDecorations.length > 0) {
return new ViewLineParts(lineNumber, lineTokens, lineContent, rawLineDecorations);
return new ViewLineParts(lineNumber, minLineColumn, lineTokens, lineContent, rawLineDecorations);
} else {
return new FastViewLineParts(lineTokens, lineContent);
}
......@@ -165,10 +165,10 @@ export class ViewLineParts implements ILineParts {
private lastPartIndex:number;
private lastEndOffset:number;
constructor(lineNumber:number, lineTokens:IViewLineTokens, lineContent:string, rawLineDecorations:ILineDecoration[]) {
constructor(lineNumber:number, minLineColumn:number, lineTokens:IViewLineTokens, lineContent:string, rawLineDecorations:ILineDecoration[]) {
// lineDecorations might overlap on top of each other, so they need to be normalized
var lineDecorations = LineDecorationsNormalizer.normalize(lineNumber, rawLineDecorations),
var lineDecorations = LineDecorationsNormalizer.normalize(lineNumber, minLineColumn, rawLineDecorations),
lineDecorationsIndex = 0,
lineDecorationsLength = lineDecorations.length;
......@@ -342,7 +342,7 @@ export class LineDecorationsNormalizer {
/**
* Normalize line decorations. Overlapping decorations will generate multiple segments
*/
public static normalize(lineNumber:number, lineDecorations:ILineDecoration[]): DecorationSegment[] {
public static normalize(lineNumber:number, minLineColumn:number, lineDecorations:ILineDecoration[]): DecorationSegment[] {
var result:DecorationSegment[] = [];
......@@ -371,7 +371,7 @@ export class LineDecorationsNormalizer {
continue;
}
currentStartOffset = (d.range.startLineNumber === lineNumber ? d.range.startColumn - 1 : 0);
currentStartOffset = (d.range.startLineNumber === lineNumber ? d.range.startColumn - 1 : minLineColumn - 1);
currentEndOffset = (d.range.endLineNumber === lineNumber ? d.range.endColumn - 2 : LineDecorationsNormalizer.MAX_LINE_LENGTH - 1);
if (currentEndOffset < 0) {
......
......@@ -25,7 +25,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
test('Bug 9827:Overlapping inline decorations can cause wrong inline class to be applied', () => {
var result = LineDecorationsNormalizer.normalize(1, [
var result = LineDecorationsNormalizer.normalize(1, 1, [
newDecoration(1, 1, 1, 11, 'c1'),
newDecoration(1, 3, 1, 4, 'c2')
]);
......@@ -39,7 +39,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
test('issue #3462: no whitespace shown at the end of a decorated line', () => {
var result = LineDecorationsNormalizer.normalize(3, [
var result = LineDecorationsNormalizer.normalize(3, 1, [
newDecoration(3, 15, 3, 21, 'trailing whitespace'),
newDecoration(3, 20, 3, 21, 'inline-folded'),
]);
......@@ -50,9 +50,20 @@ suite('Editor ViewLayout - ViewLineParts', () => {
]);
});
test('issue #3661: Link decoration bleeds to next line when wrapping', () => {
var result = LineDecorationsNormalizer.normalize(3, 12, [
newDecoration(2, 12, 3, 30, 'detected-link')
]);
assert.deepEqual(result, [
new DecorationSegment(11, 28, 'detected-link'),
]);
});
test('ViewLineParts', () => {
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
assert.deepEqual(LineDecorationsNormalizer.normalize(1, 1, [
newDecoration(1, 1, 1, 2, 'c1'),
newDecoration(1, 3, 1, 4, 'c2')
]), [
......@@ -60,7 +71,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new DecorationSegment(2, 2, 'c2')
]);
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
assert.deepEqual(LineDecorationsNormalizer.normalize(1, 1, [
newDecoration(1, 1, 1, 3, 'c1'),
newDecoration(1, 3, 1, 4, 'c2')
]), [
......@@ -68,7 +79,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new DecorationSegment(2, 2, 'c2')
]);
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
assert.deepEqual(LineDecorationsNormalizer.normalize(1, 1, [
newDecoration(1, 1, 1, 4, 'c1'),
newDecoration(1, 3, 1, 4, 'c2')
]), [
......@@ -76,7 +87,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new DecorationSegment(2, 2, 'c1 c2')
]);
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
assert.deepEqual(LineDecorationsNormalizer.normalize(1, 1, [
newDecoration(1, 1, 1, 4, 'c1'),
newDecoration(1, 1, 1, 4, 'c1*'),
newDecoration(1, 3, 1, 4, 'c2')
......@@ -85,7 +96,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new DecorationSegment(2, 2, 'c1 c1* c2')
]);
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
assert.deepEqual(LineDecorationsNormalizer.normalize(1, 1, [
newDecoration(1, 1, 1, 4, 'c1'),
newDecoration(1, 1, 1, 4, 'c1*'),
newDecoration(1, 1, 1, 4, 'c1**'),
......@@ -95,7 +106,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new DecorationSegment(2, 2, 'c1 c1* c1** c2')
]);
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
assert.deepEqual(LineDecorationsNormalizer.normalize(1, 1, [
newDecoration(1, 1, 1, 4, 'c1'),
newDecoration(1, 1, 1, 4, 'c1*'),
newDecoration(1, 1, 1, 4, 'c1**'),
......@@ -106,7 +117,7 @@ suite('Editor ViewLayout - ViewLineParts', () => {
new DecorationSegment(2, 2, 'c1 c1* c1** c2 c2*')
]);
assert.deepEqual(LineDecorationsNormalizer.normalize(1, [
assert.deepEqual(LineDecorationsNormalizer.normalize(1, 1, [
newDecoration(1, 1, 1, 4, 'c1'),
newDecoration(1, 1, 1, 4, 'c1*'),
newDecoration(1, 1, 1, 4, 'c1**'),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册