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

Fixes #14794: Word wrap doesn't wrap on window width for indented CJK text

上级 5a13f08c
......@@ -112,8 +112,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
let breakingLengths: number[] = []; // The length of each broken-up line text
let breakingLengthsIndex: number = 0; // The count of breaks already done
let visibleColumn = 0; // Visible column since the beginning of the current line
let breakBeforeOffset: number; // 0-based offset in the lineText before which breaking
let restoreVisibleColumnFrom: number;
let niceBreakOffset = -1; // Last index of a character that indicates a break should happen before it (more desirable)
let niceBreakVisibleColumn = 0; // visible column if a break were to be later introduced before `niceBreakOffset`
let obtrusiveBreakOffset = -1; // Last index of a character that indicates a break should happen before it (less desirable)
......@@ -133,7 +131,7 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
// Since we are certain the character before `i` fits, there's no extra checking needed,
// just mark it as a nice breaking opportunity
niceBreakOffset = i;
niceBreakVisibleColumn = 0;
niceBreakVisibleColumn = wrappedTextIndentVisibleColumn;
}
// CJK breaking : before break
......@@ -142,7 +140,7 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
let prevClass = classifier.get(prevCode);
if (prevClass !== CharacterClass.BREAK_BEFORE) { // Kinsoku Shori: Don't break after a leading character, like an open bracket
niceBreakOffset = i;
niceBreakVisibleColumn = 0;
niceBreakVisibleColumn = wrappedTextIndentVisibleColumn;
}
}
......@@ -160,6 +158,9 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
// - otherwise, break before obtrusiveBreakLastOffset if it exists (and re-establish a correct visibleColumn by using obtrusiveBreakVisibleColumn + charAt(i))
// - otherwise, break before i (and re-establish a correct visibleColumn by charAt(i))
let breakBeforeOffset: number;
let restoreVisibleColumnFrom: number;
if (niceBreakOffset !== -1) {
// We will break before `niceBreakLastOffset`
......
......@@ -44,8 +44,8 @@ function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAf
assert.equal(actualAnnotatedText, annotatedText);
}
suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
test('CharacterHardWrappingLineMapper', () => {
suite('CharacterHardWrappingLineMapper', () => {
test('latin text', () => {
let factory = new CharacterHardWrappingLineMapperFactory('(', ')', '.');
......@@ -87,7 +87,7 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
assertLineMapping(factory, 4, 5, 'aa.|(.)|.aaa');
});
test('CharacterHardWrappingLineMapper - CJK and Kinsoku Shori', () => {
test('CJK and Kinsoku Shori', () => {
let factory = new CharacterHardWrappingLineMapperFactory('(', ')', '.');
assertLineMapping(factory, 4, 5, 'aa \u5b89|\u5b89');
assertLineMapping(factory, 4, 5, '\u3042 \u5b89|\u5b89');
......@@ -97,8 +97,13 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
assertLineMapping(factory, 4, 5, 'aa |(\u5b89aa|\u5b89');
});
test('CharacterHardWrappingLineMapper - WrappingIndent.Same', () => {
test('WrappingIndent.Same', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
assertLineMapping(factory, 4, 38, ' *123456789012345678901234567890123456|7890', WrappingIndent.Same);
});
test('CJK and WrappingIndent.Same', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
assertLineMapping(factory, 4, 30, ' 协和飞机共生产了20|架,其中仅有16架投|入营运。巨大的资金', WrappingIndent.Same);
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册