提交 5fa6afd0 编写于 作者: A Alex Dima

Fixes #35162: force sticking to beginning of line only if no other characters...

Fixes #35162: force sticking to beginning of line only if no other characters than the indent would fit on a wrapped line
上级 6d00916e
......@@ -100,8 +100,8 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
wrappedTextIndent += '\t';
wrappedTextIndentVisibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(wrappedTextIndentVisibleColumn, tabSize, true, 1);
}
// Force sticking to beginning of line if indentColumn > 66% breakingColumn
if (wrappedTextIndentVisibleColumn > 1 / 2 * breakingColumn) {
// Force sticking to beginning of line if no character would fit except for the indentation
if (wrappedTextIndentVisibleColumn + columnsForFullWidthChar > breakingColumn) {
wrappedTextIndent = '';
wrappedTextIndentVisibleColumn = 0;
}
......
......@@ -7,9 +7,9 @@
import * as assert from 'assert';
import { WrappingIndent } from 'vs/editor/common/config/editorOptions';
import { CharacterHardWrappingLineMapperFactory } from 'vs/editor/common/viewModel/characterHardWrappingLineMapper';
import { ILineMapperFactory } from 'vs/editor/common/viewModel/splitLinesCollection';
import { ILineMapperFactory, ILineMapping } from 'vs/editor/common/viewModel/splitLinesCollection';
function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAfter: number, annotatedText: string, wrappingIndent = WrappingIndent.None) {
function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAfter: number, annotatedText: string, wrappingIndent = WrappingIndent.None): ILineMapping {
let rawText = '';
let currentLineIndex = 0;
......@@ -42,6 +42,8 @@ function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAf
}
assert.equal(actualAnnotatedText, annotatedText);
return mapper;
}
suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
......@@ -106,4 +108,10 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
assertLineMapping(factory, 4, 24, 'a/ very/long/line/of/tex|t/that/expands/beyon|d/your/typical/line/|of/code/', WrappingIndent.Indent);
});
test('issue #35162: wrappingIndent not consistently working', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
let mapper = assertLineMapping(factory, 4, 24, ' t h i s |i s |a l |o n |g l |i n |e', WrappingIndent.Indent);
assert.equal(mapper.getWrappedLinesIndent(), ' \t');
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册