70
71
public getBoundaryScore(length: number): number {
73
>
// 11 0 0 12 15 6 13 0 0 11
74
>
75
>
const prevCategory = getCategory(length > 0 ? this.elements[length - 1] : -1);
76
>
const nextCategory = getCategory(length < this.elements.length ? this.elements[length] : -1);
77
>
78
>
if (prevCategory === CharBoundaryCategory.LineBreakCR && nextCategory === CharBoundaryCategory.LineBreakLF) {
79
// don't break between \r and \n
80
return 0;
81
}
83
// prefer the linebreak before the change
84
return 150;
85
}
87
>
let score = 0;
88
>
if (prevCategory !== nextCategory) {
89
>
score += 10;
90
>
if (prevCategory === CharBoundaryCategory.WordLower && nextCategory === CharBoundaryCategory.WordUpper) {
91
score += 1;
92
}
94
>
95
>
score += getCategoryBoundaryScore(prevCategory);
96
>
score += getCategoryBoundaryScore(nextCategory);
97
>
98
>
return score;
99
>
}
100
101
public translateOffset(offset: number, preference: 'left' | 'right' = 'right'): Position {