Skip to content

Commit 57758d6

Browse files
committed
Remove obtrusive wrapping characters since it was used only for dot (microsoft#21196)
1 parent 09d3bbf commit 57758d6

5 files changed

Lines changed: 26 additions & 71 deletions

File tree

src/vs/editor/common/config/editorOptions.ts

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,14 @@ export interface IEditorOptions {
264264
wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
265265
/**
266266
* Configure word wrapping characters. A break will be introduced before these characters.
267-
* Defaults to '{([+'.
267+
* Defaults to '([{‘“〈《「『【〔([{「£¥$£¥++'.
268268
*/
269269
wordWrapBreakBeforeCharacters?: string;
270270
/**
271271
* Configure word wrapping characters. A break will be introduced after these characters.
272-
* Defaults to ' \t})]?|&,;'.
272+
* Defaults to ' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」'.
273273
*/
274274
wordWrapBreakAfterCharacters?: string;
275-
/**
276-
* Configure word wrapping characters. A break will be introduced after these characters only if no `wordWrapBreakBeforeCharacters` or `wordWrapBreakAfterCharacters` were found.
277-
* Defaults to '.'.
278-
*/
279-
wordWrapBreakObtrusiveCharacters?: string;
280275
/**
281276
* Performance guard: Stop rendering a line after x characters.
282277
* Defaults to 10000.
@@ -3154,7 +3149,6 @@ export const enum EditorOption {
31543149
wordWrap,
31553150
wordWrapBreakAfterCharacters,
31563151
wordWrapBreakBeforeCharacters,
3157-
wordWrapBreakObtrusiveCharacters,
31583152
wordWrapColumn,
31593153
wordWrapMinified,
31603154
wrappingIndent,
@@ -3681,16 +3675,12 @@ export const EditorOptions = {
36813675
)),
36823676
wordWrapBreakAfterCharacters: register(new EditorStringOption(
36833677
EditorOption.wordWrapBreakAfterCharacters, 'wordWrapBreakAfterCharacters',
3684-
' \t})]?|/&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
3678+
' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」',
36853679
)),
36863680
wordWrapBreakBeforeCharacters: register(new EditorStringOption(
36873681
EditorOption.wordWrapBreakBeforeCharacters, 'wordWrapBreakBeforeCharacters',
36883682
'([{‘“〈《「『【〔([{「£¥$£¥++'
36893683
)),
3690-
wordWrapBreakObtrusiveCharacters: register(new EditorStringOption(
3691-
EditorOption.wordWrapBreakObtrusiveCharacters, 'wordWrapBreakObtrusiveCharacters',
3692-
'.'
3693-
)),
36943684
wordWrapColumn: register(new EditorIntOption(
36953685
EditorOption.wordWrapColumn, 'wordWrapColumn',
36963686
80, 1, Constants.MAX_SAFE_SMALL_INTEGER,

src/vs/editor/common/viewModel/characterHardWrappingLineMapper.ts

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ const enum CharacterClass {
1515
NONE = 0,
1616
BREAK_BEFORE = 1,
1717
BREAK_AFTER = 2,
18-
BREAK_OBTRUSIVE = 3,
19-
BREAK_IDEOGRAPHIC = 4 // for Han and Kana.
18+
BREAK_IDEOGRAPHIC = 3 // for Han and Kana.
2019
}
2120

2221
class WrappingCharacterClassifier extends CharacterClassifier<CharacterClass> {
2322

24-
constructor(BREAK_BEFORE: string, BREAK_AFTER: string, BREAK_OBTRUSIVE: string) {
23+
constructor(BREAK_BEFORE: string, BREAK_AFTER: string) {
2524
super(CharacterClass.NONE);
2625

2726
for (let i = 0; i < BREAK_BEFORE.length; i++) {
@@ -31,10 +30,6 @@ class WrappingCharacterClassifier extends CharacterClassifier<CharacterClass> {
3130
for (let i = 0; i < BREAK_AFTER.length; i++) {
3231
this.set(BREAK_AFTER.charCodeAt(i), CharacterClass.BREAK_AFTER);
3332
}
34-
35-
for (let i = 0; i < BREAK_OBTRUSIVE.length; i++) {
36-
this.set(BREAK_OBTRUSIVE.charCodeAt(i), CharacterClass.BREAK_OBTRUSIVE);
37-
}
3833
}
3934

4035
public get(charCode: number): CharacterClass {
@@ -63,15 +58,14 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
6358
public static create(options: IComputedEditorOptions): CharacterHardWrappingLineMapperFactory {
6459
return new CharacterHardWrappingLineMapperFactory(
6560
options.get(EditorOption.wordWrapBreakBeforeCharacters),
66-
options.get(EditorOption.wordWrapBreakAfterCharacters),
67-
options.get(EditorOption.wordWrapBreakObtrusiveCharacters)
61+
options.get(EditorOption.wordWrapBreakAfterCharacters)
6862
);
6963
}
7064

7165
private readonly classifier: WrappingCharacterClassifier;
7266

73-
constructor(breakBeforeChars: string, breakAfterChars: string, breakObtrusiveChars: string) {
74-
this.classifier = new WrappingCharacterClassifier(breakBeforeChars, breakAfterChars, breakObtrusiveChars);
67+
constructor(breakBeforeChars: string, breakAfterChars: string) {
68+
this.classifier = new WrappingCharacterClassifier(breakBeforeChars, breakAfterChars);
7569
}
7670

7771
// TODO@Alex -> duplicated in lineCommentCommand
@@ -152,8 +146,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
152146
let visibleColumn = 0; // Visible column since the beginning of the current line
153147
let niceBreakOffset = -1; // Last index of a character that indicates a break should happen before it (more desirable)
154148
let niceBreakVisibleColumn = 0; // visible column if a break were to be later introduced before `niceBreakOffset`
155-
let obtrusiveBreakOffset = -1; // Last index of a character that indicates a break should happen before it (less desirable)
156-
let obtrusiveBreakVisibleColumn = 0; // visible column if a break were to be later introduced before `obtrusiveBreakOffset`
157149
let len = lineText.length;
158150

159151
for (let i = 0; i < len; i++) {
@@ -212,12 +204,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
212204
breakBeforeOffset = niceBreakOffset;
213205
restoreVisibleColumnFrom = niceBreakVisibleColumn;
214206

215-
} else if (obtrusiveBreakOffset !== -1 && obtrusiveBreakVisibleColumn <= breakingColumn) {
216-
217-
// We will break before `obtrusiveBreakLastOffset`
218-
breakBeforeOffset = obtrusiveBreakOffset;
219-
restoreVisibleColumnFrom = obtrusiveBreakVisibleColumn;
220-
221207
} else {
222208

223209
// We will break before `i`
@@ -236,8 +222,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
236222
// Reset markers
237223
niceBreakOffset = -1;
238224
niceBreakVisibleColumn = 0;
239-
obtrusiveBreakOffset = -1;
240-
obtrusiveBreakVisibleColumn = 0;
241225
}
242226

243227
// 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
246230
// Advance niceBreakVisibleColumn
247231
niceBreakVisibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(niceBreakVisibleColumn, tabSize, charCodeIsTab, charColumnSize);
248232
}
249-
if (obtrusiveBreakOffset !== -1) {
250-
// Advance obtrusiveBreakVisibleColumn
251-
obtrusiveBreakVisibleColumn = CharacterHardWrappingLineMapperFactory.nextVisibleColumn(obtrusiveBreakVisibleColumn, tabSize, charCodeIsTab, charColumnSize);
252-
}
253233

254234
if (charCodeClass === CharacterClass.BREAK_AFTER && (hardWrappingIndent === WrappingIndent.None || i >= firstNonWhitespaceIndex)) {
255235
// This is a character that indicates that a break should happen after it
@@ -266,12 +246,6 @@ export class CharacterHardWrappingLineMapperFactory implements ILineMapperFactor
266246
niceBreakVisibleColumn = wrappedTextIndentVisibleColumn;
267247
}
268248
}
269-
270-
if (charCodeClass === CharacterClass.BREAK_OBTRUSIVE) {
271-
// This is an obtrusive character that indicates that a break should happen after it
272-
obtrusiveBreakOffset = i + 1;
273-
obtrusiveBreakVisibleColumn = wrappedTextIndentVisibleColumn;
274-
}
275249
}
276250

277251
if (breakingLengthsIndex === 0) {

src/vs/editor/test/common/viewModel/characterHardWrappingLineMapper.test.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function assertLineMapping(factory: ILineMapperFactory, tabSize: number, breakAf
5151
suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
5252
test('CharacterHardWrappingLineMapper', () => {
5353

54-
let factory = new CharacterHardWrappingLineMapperFactory('(', ')', '.');
54+
let factory = new CharacterHardWrappingLineMapperFactory('(', ').');
5555

5656
// Empty string
5757
assertLineMapping(factory, 4, 5, '');
@@ -64,7 +64,7 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
6464
// Acts like hard wrapping if no char found
6565
assertLineMapping(factory, 4, 5, 'aaaaa|a');
6666

67-
// Honors obtrusive wrapping character
67+
// Honors wrapping character
6868
assertLineMapping(factory, 4, 5, 'aaaaa|.');
6969
assertLineMapping(factory, 4, 5, 'aaaaa|a.|aaa.|aa');
7070
assertLineMapping(factory, 4, 5, 'aaaaa|a..|aaa.|aa');
@@ -80,19 +80,19 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
8080

8181
// Honors wrapping before characters (& gives it priority)
8282
assertLineMapping(factory, 4, 5, 'aaa.|aa');
83-
assertLineMapping(factory, 4, 5, 'aaa|(.aa');
83+
assertLineMapping(factory, 4, 5, 'aaa(.|aa');
8484

8585
// Honors wrapping after characters (& gives it priority)
8686
assertLineMapping(factory, 4, 5, 'aaa))|).aaa');
87-
assertLineMapping(factory, 4, 5, 'aaa))|)|.aaaa');
88-
assertLineMapping(factory, 4, 5, 'aaa)|()|.aaa');
89-
assertLineMapping(factory, 4, 5, 'aaa(|()|.aaa');
90-
assertLineMapping(factory, 4, 5, 'aa.(|()|.aaa');
91-
assertLineMapping(factory, 4, 5, 'aa.|(.)|.aaa');
87+
assertLineMapping(factory, 4, 5, 'aaa))|).|aaaa');
88+
assertLineMapping(factory, 4, 5, 'aaa)|().|aaa');
89+
assertLineMapping(factory, 4, 5, 'aaa(|().|aaa');
90+
assertLineMapping(factory, 4, 5, 'aa.(|().|aaa');
91+
assertLineMapping(factory, 4, 5, 'aa.(.|).aaa');
9292
});
9393

9494
test('CharacterHardWrappingLineMapper - CJK and Kinsoku Shori', () => {
95-
let factory = new CharacterHardWrappingLineMapperFactory('(', ')', '.');
95+
let factory = new CharacterHardWrappingLineMapperFactory('(', ')');
9696
assertLineMapping(factory, 4, 5, 'aa \u5b89|\u5b89');
9797
assertLineMapping(factory, 4, 5, '\u3042 \u5b89|\u5b89');
9898
assertLineMapping(factory, 4, 5, '\u3042\u3042|\u5b89\u5b89');
@@ -102,28 +102,28 @@ suite('Editor ViewModel - CharacterHardWrappingLineMapper', () => {
102102
});
103103

104104
test('CharacterHardWrappingLineMapper - WrappingIndent.Same', () => {
105-
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
105+
let factory = new CharacterHardWrappingLineMapperFactory('', ' ');
106106
assertLineMapping(factory, 4, 38, ' *123456789012345678901234567890123456|7890', WrappingIndent.Same);
107107
});
108108

109109
test('issue #16332: Scroll bar overlaying on top of text', () => {
110-
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
110+
let factory = new CharacterHardWrappingLineMapperFactory('', ' ');
111111
assertLineMapping(factory, 4, 24, 'a/ very/long/line/of/tex|t/that/expands/beyon|d/your/typical/line/|of/code/', WrappingIndent.Indent);
112112
});
113113

114114
test('issue #35162: wrappingIndent not consistently working', () => {
115-
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
115+
let factory = new CharacterHardWrappingLineMapperFactory('', ' ');
116116
let mapper = assertLineMapping(factory, 4, 24, ' t h i s |i s |a l |o n |g l |i n |e', WrappingIndent.Indent);
117117
assert.equal(mapper!.getWrappedLinesIndent(), ' \t');
118118
});
119119

120120
test('issue #75494: surrogate pairs', () => {
121-
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
121+
let factory = new CharacterHardWrappingLineMapperFactory('', ' ');
122122
assertLineMapping(factory, 4, 49, '🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇|👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬🌖🌞🏇🍼🐇👬', WrappingIndent.Same);
123123
});
124124

125125
test('CharacterHardWrappingLineMapper - WrappingIndent.DeepIndent', () => {
126-
let factory = new CharacterHardWrappingLineMapperFactory('', ' ', '');
126+
let factory = new CharacterHardWrappingLineMapperFactory('', ' ');
127127
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);
128128
assert.equal(mapper!.getWrappedLinesIndent(), ' \t\t');
129129
});

src/vs/editor/test/common/viewModel/splitLinesCollection.test.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,13 +95,11 @@ suite('Editor ViewModel - SplitLinesCollection', () => {
9595
const fontInfo = config.options.get(EditorOption.fontInfo);
9696
const wordWrapBreakAfterCharacters = config.options.get(EditorOption.wordWrapBreakAfterCharacters);
9797
const wordWrapBreakBeforeCharacters = config.options.get(EditorOption.wordWrapBreakBeforeCharacters);
98-
const wordWrapBreakObtrusiveCharacters = config.options.get(EditorOption.wordWrapBreakObtrusiveCharacters);
9998
const wrappingIndent = config.options.get(EditorOption.wrappingIndent);
10099

101100
const hardWrappingLineMapperFactory = new CharacterHardWrappingLineMapperFactory(
102101
wordWrapBreakBeforeCharacters,
103-
wordWrapBreakAfterCharacters,
104-
wordWrapBreakObtrusiveCharacters
102+
wordWrapBreakAfterCharacters
105103
);
106104

107105
const model = TextModel.createFromString([
@@ -749,13 +747,11 @@ suite('SplitLinesCollection', () => {
749747
const fontInfo = configuration.options.get(EditorOption.fontInfo);
750748
const wordWrapBreakAfterCharacters = configuration.options.get(EditorOption.wordWrapBreakAfterCharacters);
751749
const wordWrapBreakBeforeCharacters = configuration.options.get(EditorOption.wordWrapBreakBeforeCharacters);
752-
const wordWrapBreakObtrusiveCharacters = configuration.options.get(EditorOption.wordWrapBreakObtrusiveCharacters);
753750
const wrappingIndent = configuration.options.get(EditorOption.wrappingIndent);
754751

755752
const factory = new CharacterHardWrappingLineMapperFactory(
756753
wordWrapBreakBeforeCharacters,
757-
wordWrapBreakAfterCharacters,
758-
wordWrapBreakObtrusiveCharacters
754+
wordWrapBreakAfterCharacters
759755
);
760756

761757
const linesCollection = new SplitLinesCollection(

src/vs/monaco.d.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,19 +2709,14 @@ declare namespace monaco.editor {
27092709
wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
27102710
/**
27112711
* Configure word wrapping characters. A break will be introduced before these characters.
2712-
* Defaults to '{([+'.
2712+
* Defaults to '([{‘“〈《「『【〔([{「£¥$£¥++'.
27132713
*/
27142714
wordWrapBreakBeforeCharacters?: string;
27152715
/**
27162716
* Configure word wrapping characters. A break will be introduced after these characters.
2717-
* Defaults to ' \t})]?|&,;'.
2717+
* Defaults to ' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」'.
27182718
*/
27192719
wordWrapBreakAfterCharacters?: string;
2720-
/**
2721-
* Configure word wrapping characters. A break will be introduced after these characters only if no `wordWrapBreakBeforeCharacters` or `wordWrapBreakAfterCharacters` were found.
2722-
* Defaults to '.'.
2723-
*/
2724-
wordWrapBreakObtrusiveCharacters?: string;
27252720
/**
27262721
* Performance guard: Stop rendering a line after x characters.
27272722
* Defaults to 10000.

0 commit comments

Comments
 (0)