Remove obtrusive wrapping characters since it was used only for dot (#21196)

上级 09d3bbf7
......@@ -264,19 +264,14 @@ export interface IEditorOptions {
wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
/**
* Configure word wrapping characters. A break will be introduced before these characters.
* Defaults to '{([+'.
* Defaults to '([{‘“〈《「『【〔([{「£¥$£¥++'.
*/
wordWrapBreakBeforeCharacters?: string;
/**
* Configure word wrapping characters. A break will be introduced after these characters.
* Defaults to ' \t})]?|&,;'.
* Defaults to ' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」'.
*/
wordWrapBreakAfterCharacters?: string;
/**
* Configure word wrapping characters. A break will be introduced after these characters only if no `wordWrapBreakBeforeCharacters` or `wordWrapBreakAfterCharacters` were found.
* Defaults to '.'.
*/
wordWrapBreakObtrusiveCharacters?: string;
/**
* Performance guard: Stop rendering a line after x characters.
* Defaults to 10000.
......@@ -3154,7 +3149,6 @@ export const enum EditorOption {
wordWrap,
wordWrapBreakAfterCharacters,
wordWrapBreakBeforeCharacters,
wordWrapBreakObtrusiveCharacters,
wordWrapColumn,
wordWrapMinified,
wrappingIndent,
......@@ -3681,16 +3675,12 @@ export const EditorOptions = {
)),
wordWrapBreakAfterCharacters: register(new EditorStringOption(
EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters',
' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
)),
wordWrapBreakBeforeCharacters: register(new EditorStringOption(
EditorOption.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters',
'([{‘“〈《「『【〔([{「£¥$£¥++'
)),
wordWrapBreakObtrusiveCharacters: register(new EditorStringOption(
EditorOption.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters',
'.'
)),
wordWrapColumn: register(new EditorIntOption(
EditorOption.wordWrapColumn, 'wordWrapColumn',
80, 1, Constants.MAX_SAFE_SMALL_INTEGER,
......
......@@ -15,13 +15,12 @@ const enum CharacterClass {
NONE = 0,
BREAK_BEFORE = 1,
BREAK_AFTER = 2,
BREAK_OBTRUSIVE = 3,
BREAK_IDEOGRAPHIC = 4 // for Han and Kana.
BREAK_IDEOGRAPHIC = 3 // for Han and Kana.
}
class WrappingCharacterClassifier extends CharacterClassifier<CharacterClass> {
constructor(BREAK_BEFORE: string, BREAK_AFTER: string, BREAK_OBTRUSIVE: string) {
constructor(BREAK_BEFORE: string, BREAK_AFTER: string) {
super(CharacterClass.NONE);
for (let i = 0; i < BREAK_BEFORE.length; i++) {
......@@ -31,10 +30,6 @@ class WrappingCharacterClassifier extends CharacterClassifier<CharacterClass> {
for (let i = 0; i < BREAK_AFTER.length; i++) {
this.set(BREAK_AFTER.charCodeAt(i), CharacterClass.BREAK_AFTER);
}
for (let i = 0; i < BREAK_OBTRUSIVE.length; i++) {
this.set(BREAK_OBTRUSIVE.charCodeAt(i), CharacterClass.BREAK_OBTRUSIVE);
}
}
public get(charCode: number): CharacterClass {
......@@ -63,15 +58,14 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
public static create(options: IComputedEditorOptions): CharacterHardWrappingLineMapperFactory {
return new CharacterHardWrappingLineMapperFactory(
options.get(EditorOption.wordWrapBreakBeforeCharacters),
options.get(EditorOption.wordWrapBreakAfterCharacters),
options.get(EditorOption.wordWrapBreakObtrusiveCharacters)
options.get(EditorOption.wordWrapBreakAfterCharacters)
);
}
private readonly classifier: WrappingCharacterClassifier;
constructor(breakBeforeChars: string, breakAfterChars: string, breakObtrusiveChars: string) {
this.classifier = new WrappingCharacterClassifier(breakBeforeChars, breakAfterChars, breakObtrusiveChars);
constructor(breakBeforeChars: string, breakAfterChars: string) {
this.classifier = new WrappingCharacterClassifier(breakBeforeChars, breakAfterChars);
}
// TODO@Alex -> duplicated in lineCommentCommand
......@@ -152,8 +146,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
let visibleColumn = 0; // Visible column since the beginning of the current line
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)
let obtrusiveBreakVisibleColumn = 0; // visible column if a break were to be later introduced before `obtrusiveBreakOffset`
let len = lineText.length;
for (let i = 0; i < len; i++) {
......@@ -212,12 +204,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
breakBeforeOffset = niceBreakOffset;
restoreVisibleColumnFrom = niceBreakVisibleColumn;
} else if (obtrusiveBreakOffset !== -1 && obtrusiveBreakVisibleColumn <= breakingColumn) {
// We will break before `obtrusiveBreakLastOffset`
breakBeforeOffset = obtrusiveBreakOffset;
restoreVisibleColumnFrom = obtrusiveBreakVisibleColumn;
} else {
// We will break before `i`
......@@ -236,8 +222,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
// Reset markers
niceBreakOffset = -1;
niceBreakVisibleColumn = 0;
obtrusiveBreakOffset = -1;
obtrusiveBreakVisibleColumn = 0;
}
// At this point, there is a certainty that the character at `i` fits on the current line
......@@ -246,10 +230,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
// Advance niceBreakVisibleColumn
niceBreakVisibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(niceBreakVisibleColumn, tabSize, charCodeIsTab, charColumnSize);
}
if (obtrusiveBreakOffset !== -1) {
// Advance obtrusiveBreakVisibleColumn
obtrusiveBreakVisibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(obtrusiveBreakVisibleColumn, tabSize, charCodeIsTab, charColumnSize);
}
if (charCodeClass === CharacterClass.BREAK_AFTER && (hardWrappingIndent === WrappingIndent.None || i >= firstNonWhitespaceIndex)) {
// This is a character that indicates that a break should happen after it
......@@ -266,12 +246,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
niceBreakVisibleColumn = wrappedTextIndentVisibleColumn;
}
}
if (charCodeClass === CharacterClass.BREAK_OBTRUSIVE) {
// This is an obtrusive character that indicates that a break should happen after it
obtrusiveBreakOffset = i + 1;
obtrusiveBreakVisibleColumn = wrappedTextIndentVisibleColumn;
}
}
if (breakingLengthsIndex === 0) {
......
......@@ -51,7 +51,7 @@ function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAf
suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
test('CharacterHardWrappingLineMapper', () => {
let factory = new CharacterHardWrappingLineMapperFactory('(', ')', '.');
let factory = new CharacterHardWrappingLineMapperFactory('(', ').');
// Empty string
assertLineMapping(factory, 4, 5, '');
......@@ -64,7 +64,7 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
// Acts like hard wrapping if no char found
assertLineMapping(factory, 4, 5, 'aaaaa|a');
// Honors obtrusive wrapping character
// Honors wrapping character
assertLineMapping(factory, 4, 5, 'aaaaa|.');
assertLineMapping(factory, 4, 5, 'aaaaa|a.|aaa.|aa');
assertLineMapping(factory, 4, 5, 'aaaaa|a..|aaa.|aa');
......@@ -80,19 +80,19 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
// Honors wrapping before characters (& gives it priority)
assertLineMapping(factory, 4, 5, 'aaa.|aa');
assertLineMapping(factory, 4, 5, 'aaa|(.aa');
assertLineMapping(factory, 4, 5, 'aaa(.|aa');
// Honors wrapping after characters (& gives it priority)
assertLineMapping(factory, 4, 5, 'aaa))|).aaa');
assertLineMapping(factory, 4, 5, 'aaa))|)|.aaaa');
assertLineMapping(factory, 4, 5, 'aaa)|()|.aaa');
assertLineMapping(factory, 4, 5, 'aaa(|()|.aaa');
assertLineMapping(factory, 4, 5, 'aa.(|()|.aaa');
assertLineMapping(factory, 4, 5, 'aa.|(.)|.aaa');
assertLineMapping(factory, 4, 5, 'aaa))|).|aaaa');
assertLineMapping(factory, 4, 5, 'aaa)|().|aaa');
assertLineMapping(factory, 4, 5, 'aaa(|().|aaa');
assertLineMapping(factory, 4, 5, 'aa.(|().|aaa');
assertLineMapping(factory, 4, 5, 'aa.(.|).aaa');
});
test('CharacterHardWrappingLineMapper - CJK and Kinsoku Shori', () => {
let factory = new CharacterHardWrappingLineMapperFactory('(', ')', '.');
let factory = new CharacterHardWrappingLineMapperFactory('(', ')');
assertLineMapping(factory, 4, 5, 'aa \u5b89|\u5b89');
assertLineMapping(factory, 4, 5, '\u3042 \u5b89|\u5b89');
assertLineMapping(factory, 4, 5, '\u3042\u3042|\u5b89\u5b89');
......@@ -102,28 +102,28 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
});
test('CharacterHardWrappingLineMapper - WrappingIndent.Same', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
let factory = new CharacterHardWrappingLineMapperFactory('', ' ');
assertLineMapping(factory, 4, 38, ' *123456789012345678901234567890123456|7890', WrappingIndent.Same);
});
test('issue #16332: Scroll bar overlaying on top of text', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
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 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');
});
test('issue #75494: surrogate pairs', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
let factory = new CharacterHardWrappingLineMapperFactory('', ' ');
assertLineMapping(factory, 4, 49, '🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇|👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬', WrappingIndent.Same);
});
test('CharacterHardWrappingLineMapper - WrappingIndent.DeepIndent', () => {
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
let factory = new CharacterHardWrappingLineMapperFactory('', ' ');
let mapper = assertLineMapping(factory, 4, 26, ' W e A r e T e s t |i n g D e |e p I n d |e n t a t |i o n', WrappingIndent.DeepIndent);
assert.equal(mapper!.getWrappedLinesIndent(), ' \t\t');
});
......
......@@ -95,13 +95,11 @@ suite('Editor ViewModel - SplitLinesCollection', () => {
const fontInfo = config.options.get(EditorOption.fontInfo);
const wordWrapBreakAfterCharacters = config.options.get(EditorOption.wordWrapBreakAfterCharacters);
const wordWrapBreakBeforeCharacters = config.options.get(EditorOption.wordWrapBreakBeforeCharacters);
const wordWrapBreakObtrusiveCharacters = config.options.get(EditorOption.wordWrapBreakObtrusiveCharacters);
const wrappingIndent = config.options.get(EditorOption.wrappingIndent);
const hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory(
wordWrapBreakBeforeCharacters,
wordWrapBreakAfterCharacters,
wordWrapBreakObtrusiveCharacters
wordWrapBreakAfterCharacters
);
const model = TextModel.createFromString([
......@@ -749,13 +747,11 @@ suite('SplitLinesCollection', () => {
const fontInfo = configuration.options.get(EditorOption.fontInfo);
const wordWrapBreakAfterCharacters = configuration.options.get(EditorOption.wordWrapBreakAfterCharacters);
const wordWrapBreakBeforeCharacters = configuration.options.get(EditorOption.wordWrapBreakBeforeCharacters);
const wordWrapBreakObtrusiveCharacters = configuration.options.get(EditorOption.wordWrapBreakObtrusiveCharacters);
const wrappingIndent = configuration.options.get(EditorOption.wrappingIndent);
const factory = new CharacterHardWrappingLineMapperFactory(
wordWrapBreakBeforeCharacters,
wordWrapBreakAfterCharacters,
wordWrapBreakObtrusiveCharacters
wordWrapBreakAfterCharacters
);
const linesCollection = new SplitLinesCollection(
......
......@@ -2709,19 +2709,14 @@ declare namespace monaco.editor {
wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
/**
* Configure word wrapping characters. A break will be introduced before these characters.
* Defaults to '{([+'.
* Defaults to '([{‘“〈《「『【〔([{「£¥$£¥++'.
*/
wordWrapBreakBeforeCharacters?: string;
/**
* Configure word wrapping characters. A break will be introduced after these characters.
* Defaults to ' \t})]?|&,;'.
* Defaults to ' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」'.
*/
wordWrapBreakAfterCharacters?: string;
/**
* Configure word wrapping characters. A break will be introduced after these characters only if no `wordWrapBreakBeforeCharacters` or `wordWrapBreakAfterCharacters` were found.
* Defaults to '.'.
*/
wordWrapBreakObtrusiveCharacters?: string;
/**
* Performance guard: Stop rendering a line after x characters.
* Defaults to 10000.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册