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

Fixes #21476: Hard break at 100 column which break ligature for Fira Code

上级 364e5efb
...@@ -106,6 +106,7 @@ export class Colorizer { ...@@ -106,6 +106,7 @@ export class Colorizer {
0, 0,
-1, -1,
'none', 'none',
false,
false false
)); ));
return renderResult.html; return renderResult.html;
...@@ -147,6 +148,7 @@ function _fakeColorize(lines: string[], tabSize: number): string { ...@@ -147,6 +148,7 @@ function _fakeColorize(lines: string[], tabSize: number): string {
0, 0,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -176,6 +178,7 @@ function _actualColorize(lines: string[], tabSize: number, tokenizationSupport: ...@@ -176,6 +178,7 @@ function _actualColorize(lines: string[], tabSize: number, tokenizationSupport:
0, 0,
-1, -1,
'none', 'none',
false,
false false
)); ));
......
...@@ -72,6 +72,7 @@ export class ViewLineOptions { ...@@ -72,6 +72,7 @@ export class ViewLineOptions {
public readonly useMonospaceOptimizations: boolean; public readonly useMonospaceOptimizations: boolean;
public readonly lineHeight: number; public readonly lineHeight: number;
public readonly stopRenderingLineAfter: number; public readonly stopRenderingLineAfter: number;
public readonly fontLigatures: boolean;
constructor(config: IConfiguration) { constructor(config: IConfiguration) {
this.renderWhitespace = config.editor.viewInfo.renderWhitespace; this.renderWhitespace = config.editor.viewInfo.renderWhitespace;
...@@ -83,6 +84,7 @@ export class ViewLineOptions { ...@@ -83,6 +84,7 @@ export class ViewLineOptions {
); );
this.lineHeight = config.editor.lineHeight; this.lineHeight = config.editor.lineHeight;
this.stopRenderingLineAfter = config.editor.viewInfo.stopRenderingLineAfter; this.stopRenderingLineAfter = config.editor.viewInfo.stopRenderingLineAfter;
this.fontLigatures = config.editor.viewInfo.fontLigatures;
} }
public equals(other: ViewLineOptions): boolean { public equals(other: ViewLineOptions): boolean {
...@@ -93,6 +95,7 @@ export class ViewLineOptions { ...@@ -93,6 +95,7 @@ export class ViewLineOptions {
&& this.useMonospaceOptimizations === other.useMonospaceOptimizations && this.useMonospaceOptimizations === other.useMonospaceOptimizations
&& this.lineHeight === other.lineHeight && this.lineHeight === other.lineHeight
&& this.stopRenderingLineAfter === other.stopRenderingLineAfter && this.stopRenderingLineAfter === other.stopRenderingLineAfter
&& this.fontLigatures === other.fontLigatures
); );
} }
} }
...@@ -161,7 +164,8 @@ export class ViewLine implements IVisibleLine { ...@@ -161,7 +164,8 @@ export class ViewLine implements IVisibleLine {
options.spaceWidth, options.spaceWidth,
options.stopRenderingLineAfter, options.stopRenderingLineAfter,
options.renderWhitespace, options.renderWhitespace,
options.renderControlCharacters options.renderControlCharacters,
options.fontLigatures
); );
if (this._renderedViewLine && this._renderedViewLine.input.equals(renderLineInput)) { if (this._renderedViewLine && this._renderedViewLine.input.equals(renderLineInput)) {
......
...@@ -1930,7 +1930,8 @@ class InlineViewZonesComputer extends ViewZonesComputer { ...@@ -1930,7 +1930,8 @@ class InlineViewZonesComputer extends ViewZonesComputer {
config.fontInfo.spaceWidth, config.fontInfo.spaceWidth,
config.viewInfo.stopRenderingLineAfter, config.viewInfo.stopRenderingLineAfter,
config.viewInfo.renderWhitespace, config.viewInfo.renderWhitespace,
config.viewInfo.renderControlCharacters config.viewInfo.renderControlCharacters,
config.viewInfo.fontLigatures
)); ));
let myResult: string[] = []; let myResult: string[] = [];
......
...@@ -290,6 +290,7 @@ class InternalEditorOptionsHelper { ...@@ -290,6 +290,7 @@ class InternalEditorOptionsHelper {
stopRenderingLineAfter: stopRenderingLineAfter, stopRenderingLineAfter: stopRenderingLineAfter,
renderWhitespace: renderWhitespace, renderWhitespace: renderWhitespace,
renderControlCharacters: toBoolean(opts.renderControlCharacters), renderControlCharacters: toBoolean(opts.renderControlCharacters),
fontLigatures: toBoolean(opts.fontLigatures),
renderIndentGuides: toBoolean(opts.renderIndentGuides), renderIndentGuides: toBoolean(opts.renderIndentGuides),
renderLineHighlight: renderLineHighlight, renderLineHighlight: renderLineHighlight,
scrollbar: scrollbar, scrollbar: scrollbar,
......
...@@ -788,6 +788,7 @@ export class InternalEditorViewOptions { ...@@ -788,6 +788,7 @@ export class InternalEditorViewOptions {
readonly stopRenderingLineAfter: number; readonly stopRenderingLineAfter: number;
readonly renderWhitespace: 'none' | 'boundary' | 'all'; readonly renderWhitespace: 'none' | 'boundary' | 'all';
readonly renderControlCharacters: boolean; readonly renderControlCharacters: boolean;
readonly fontLigatures: boolean;
readonly renderIndentGuides: boolean; readonly renderIndentGuides: boolean;
readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
readonly scrollbar: InternalEditorScrollbarOptions; readonly scrollbar: InternalEditorScrollbarOptions;
...@@ -822,6 +823,7 @@ export class InternalEditorViewOptions { ...@@ -822,6 +823,7 @@ export class InternalEditorViewOptions {
stopRenderingLineAfter: number; stopRenderingLineAfter: number;
renderWhitespace: 'none' | 'boundary' | 'all'; renderWhitespace: 'none' | 'boundary' | 'all';
renderControlCharacters: boolean; renderControlCharacters: boolean;
fontLigatures: boolean;
renderIndentGuides: boolean; renderIndentGuides: boolean;
renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
scrollbar: InternalEditorScrollbarOptions; scrollbar: InternalEditorScrollbarOptions;
...@@ -852,6 +854,7 @@ export class InternalEditorViewOptions { ...@@ -852,6 +854,7 @@ export class InternalEditorViewOptions {
this.stopRenderingLineAfter = source.stopRenderingLineAfter | 0; this.stopRenderingLineAfter = source.stopRenderingLineAfter | 0;
this.renderWhitespace = source.renderWhitespace; this.renderWhitespace = source.renderWhitespace;
this.renderControlCharacters = Boolean(source.renderControlCharacters); this.renderControlCharacters = Boolean(source.renderControlCharacters);
this.fontLigatures = Boolean(source.fontLigatures);
this.renderIndentGuides = Boolean(source.renderIndentGuides); this.renderIndentGuides = Boolean(source.renderIndentGuides);
this.renderLineHighlight = source.renderLineHighlight; this.renderLineHighlight = source.renderLineHighlight;
this.scrollbar = source.scrollbar.clone(); this.scrollbar = source.scrollbar.clone();
...@@ -916,6 +919,7 @@ export class InternalEditorViewOptions { ...@@ -916,6 +919,7 @@ export class InternalEditorViewOptions {
&& this.stopRenderingLineAfter === other.stopRenderingLineAfter && this.stopRenderingLineAfter === other.stopRenderingLineAfter
&& this.renderWhitespace === other.renderWhitespace && this.renderWhitespace === other.renderWhitespace
&& this.renderControlCharacters === other.renderControlCharacters && this.renderControlCharacters === other.renderControlCharacters
&& this.fontLigatures === other.fontLigatures
&& this.renderIndentGuides === other.renderIndentGuides && this.renderIndentGuides === other.renderIndentGuides
&& this.renderLineHighlight === other.renderLineHighlight && this.renderLineHighlight === other.renderLineHighlight
&& this.scrollbar.equals(other.scrollbar) && this.scrollbar.equals(other.scrollbar)
...@@ -953,6 +957,7 @@ export class InternalEditorViewOptions { ...@@ -953,6 +957,7 @@ export class InternalEditorViewOptions {
stopRenderingLineAfter: this.stopRenderingLineAfter !== newOpts.stopRenderingLineAfter, stopRenderingLineAfter: this.stopRenderingLineAfter !== newOpts.stopRenderingLineAfter,
renderWhitespace: this.renderWhitespace !== newOpts.renderWhitespace, renderWhitespace: this.renderWhitespace !== newOpts.renderWhitespace,
renderControlCharacters: this.renderControlCharacters !== newOpts.renderControlCharacters, renderControlCharacters: this.renderControlCharacters !== newOpts.renderControlCharacters,
fontLigatures: this.fontLigatures !== newOpts.fontLigatures,
renderIndentGuides: this.renderIndentGuides !== newOpts.renderIndentGuides, renderIndentGuides: this.renderIndentGuides !== newOpts.renderIndentGuides,
renderLineHighlight: this.renderLineHighlight !== newOpts.renderLineHighlight, renderLineHighlight: this.renderLineHighlight !== newOpts.renderLineHighlight,
scrollbar: (!this.scrollbar.equals(newOpts.scrollbar)), scrollbar: (!this.scrollbar.equals(newOpts.scrollbar)),
...@@ -994,6 +999,7 @@ export interface IViewConfigurationChangedEvent { ...@@ -994,6 +999,7 @@ export interface IViewConfigurationChangedEvent {
readonly stopRenderingLineAfter: boolean; readonly stopRenderingLineAfter: boolean;
readonly renderWhitespace: boolean; readonly renderWhitespace: boolean;
readonly renderControlCharacters: boolean; readonly renderControlCharacters: boolean;
readonly fontLigatures: boolean;
readonly renderIndentGuides: boolean; readonly renderIndentGuides: boolean;
readonly renderLineHighlight: boolean; readonly renderLineHighlight: boolean;
readonly scrollbar: boolean; readonly scrollbar: boolean;
......
...@@ -43,6 +43,7 @@ export class RenderLineInput { ...@@ -43,6 +43,7 @@ export class RenderLineInput {
public readonly stopRenderingLineAfter: number; public readonly stopRenderingLineAfter: number;
public readonly renderWhitespace: RenderWhitespace; public readonly renderWhitespace: RenderWhitespace;
public readonly renderControlCharacters: boolean; public readonly renderControlCharacters: boolean;
public readonly fontLigatures: boolean;
constructor( constructor(
useMonospaceOptimizations: boolean, useMonospaceOptimizations: boolean,
...@@ -56,6 +57,7 @@ export class RenderLineInput { ...@@ -56,6 +57,7 @@ export class RenderLineInput {
stopRenderingLineAfter: number, stopRenderingLineAfter: number,
renderWhitespace: 'none' | 'boundary' | 'all', renderWhitespace: 'none' | 'boundary' | 'all',
renderControlCharacters: boolean, renderControlCharacters: boolean,
fontLigatures: boolean
) { ) {
this.useMonospaceOptimizations = useMonospaceOptimizations; this.useMonospaceOptimizations = useMonospaceOptimizations;
this.lineContent = lineContent; this.lineContent = lineContent;
...@@ -74,6 +76,7 @@ export class RenderLineInput { ...@@ -74,6 +76,7 @@ export class RenderLineInput {
: RenderWhitespace.None : RenderWhitespace.None
); );
this.renderControlCharacters = renderControlCharacters; this.renderControlCharacters = renderControlCharacters;
this.fontLigatures = fontLigatures;
} }
public equals(other: RenderLineInput): boolean { public equals(other: RenderLineInput): boolean {
...@@ -87,6 +90,7 @@ export class RenderLineInput { ...@@ -87,6 +90,7 @@ export class RenderLineInput {
&& this.stopRenderingLineAfter === other.stopRenderingLineAfter && this.stopRenderingLineAfter === other.stopRenderingLineAfter
&& this.renderWhitespace === other.renderWhitespace && this.renderWhitespace === other.renderWhitespace
&& this.renderControlCharacters === other.renderControlCharacters && this.renderControlCharacters === other.renderControlCharacters
&& this.fontLigatures === other.fontLigatures
&& LineDecoration.equalsArr(this.lineDecorations, other.lineDecorations) && LineDecoration.equalsArr(this.lineDecorations, other.lineDecorations)
&& ViewLineToken.equalsArr(this.lineTokens, other.lineTokens) && ViewLineToken.equalsArr(this.lineTokens, other.lineTokens)
); );
...@@ -297,7 +301,7 @@ function resolveRenderLineInput(input: RenderLineInput): ResolvedRenderLineInput ...@@ -297,7 +301,7 @@ function resolveRenderLineInput(input: RenderLineInput): ResolvedRenderLineInput
if (input.mightContainRTL) { if (input.mightContainRTL) {
containsRTL = strings.containsRTL(lineContent); containsRTL = strings.containsRTL(lineContent);
} }
if (!containsRTL) { if (!containsRTL && !input.fontLigatures) {
tokens = splitLargeTokens(lineContent, tokens); tokens = splitLargeTokens(lineContent, tokens);
} }
......
...@@ -31,6 +31,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -31,6 +31,7 @@ suite('viewLineRenderer.renderLine', () => {
0, 0,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -78,6 +79,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -78,6 +79,7 @@ suite('viewLineRenderer.renderLine', () => {
0, 0,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -127,6 +129,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -127,6 +129,7 @@ suite('viewLineRenderer.renderLine', () => {
10, 10,
6, 6,
'boundary', 'boundary',
false,
false false
)); ));
...@@ -212,6 +215,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -212,6 +215,7 @@ suite('viewLineRenderer.renderLine', () => {
10, 10,
-1, -1,
'boundary', 'boundary',
false,
false false
)); ));
...@@ -271,6 +275,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -271,6 +275,7 @@ suite('viewLineRenderer.renderLine', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -330,6 +335,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -330,6 +335,7 @@ suite('viewLineRenderer.renderLine', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -366,6 +372,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -366,6 +372,7 @@ suite('viewLineRenderer.renderLine', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -392,6 +399,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -392,6 +399,7 @@ suite('viewLineRenderer.renderLine', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
assert.equal(actual.html, '<span>' + expectedOutput.join('') + '</span>', message); assert.equal(actual.html, '<span>' + expectedOutput.join('') + '</span>', message);
...@@ -469,6 +477,43 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -469,6 +477,43 @@ suite('viewLineRenderer.renderLine', () => {
} }
}); });
test('issue #21476: Does not split large tokens when ligatures are on', () => {
// 1 1 1
// 1 2 3 4 5 6 7 8 9 0 1 2
// 1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234
let _lineText = 'This is just a long line that contains very interesting text. This is just a long line that contains very interesting text.';
function assertSplitsTokens(message: string, lineText: string, expectedOutput: string[]): void {
let lineParts = [createPart(lineText.length, 1)];
let actual = renderViewLine(new RenderLineInput(
false,
lineText,
false,
0,
lineParts,
[],
4,
10,
-1,
'none',
false,
true
));
assert.equal(actual.html, '<span>' + expectedOutput.join('') + '</span>', message);
}
// A token with 101 chars
{
assertSplitsTokens(
'101 chars',
_lineText.substr(0, 101),
[
'<span class="mtk1">This&nbsp;is&nbsp;just&nbsp;a&nbsp;long&nbsp;line&nbsp;that&nbsp;contains&nbsp;very&nbsp;interesting&nbsp;text.&nbsp;This&nbsp;is&nbsp;just&nbsp;a&nbsp;long&nbsp;line&nbsp;that&nbsp;contains&nbsp;</span>',
]
);
}
});
test('issue #20624: Unaligned surrogate pairs are corrupted at multiples of 50 columns', () => { test('issue #20624: Unaligned surrogate pairs are corrupted at multiples of 50 columns', () => {
let lineText = 'a𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷'; let lineText = 'a𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷𠮷';
...@@ -484,6 +529,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -484,6 +529,7 @@ suite('viewLineRenderer.renderLine', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
let expectedOutput = [ let expectedOutput = [
...@@ -513,6 +559,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -513,6 +559,7 @@ suite('viewLineRenderer.renderLine', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
assert.equal(actual.html, '<span>' + expectedOutput.join('') + '</span>'); assert.equal(actual.html, '<span>' + expectedOutput.join('') + '</span>');
...@@ -555,6 +602,7 @@ suite('viewLineRenderer.renderLine', () => { ...@@ -555,6 +602,7 @@ suite('viewLineRenderer.renderLine', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -623,6 +671,7 @@ suite('viewLineRenderer.renderLine 2', () => { ...@@ -623,6 +671,7 @@ suite('viewLineRenderer.renderLine 2', () => {
10, 10,
-1, -1,
renderWhitespace, renderWhitespace,
false,
false false
)); ));
...@@ -644,6 +693,7 @@ suite('viewLineRenderer.renderLine 2', () => { ...@@ -644,6 +693,7 @@ suite('viewLineRenderer.renderLine 2', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -679,6 +729,7 @@ suite('viewLineRenderer.renderLine 2', () => { ...@@ -679,6 +729,7 @@ suite('viewLineRenderer.renderLine 2', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -938,6 +989,7 @@ suite('viewLineRenderer.renderLine 2', () => { ...@@ -938,6 +989,7 @@ suite('viewLineRenderer.renderLine 2', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
...@@ -971,6 +1023,7 @@ suite('viewLineRenderer.renderLine 2', () => { ...@@ -971,6 +1023,7 @@ suite('viewLineRenderer.renderLine 2', () => {
10, 10,
-1, -1,
'none', 'none',
false,
false false
)); ));
......
...@@ -1564,6 +1564,7 @@ declare module monaco.editor { ...@@ -1564,6 +1564,7 @@ declare module monaco.editor {
readonly stopRenderingLineAfter: number; readonly stopRenderingLineAfter: number;
readonly renderWhitespace: 'none' | 'boundary' | 'all'; readonly renderWhitespace: 'none' | 'boundary' | 'all';
readonly renderControlCharacters: boolean; readonly renderControlCharacters: boolean;
readonly fontLigatures: boolean;
readonly renderIndentGuides: boolean; readonly renderIndentGuides: boolean;
readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all'; readonly renderLineHighlight: 'none' | 'gutter' | 'line' | 'all';
readonly scrollbar: InternalEditorScrollbarOptions; readonly scrollbar: InternalEditorScrollbarOptions;
...@@ -1596,6 +1597,7 @@ declare module monaco.editor { ...@@ -1596,6 +1597,7 @@ declare module monaco.editor {
readonly stopRenderingLineAfter: boolean; readonly stopRenderingLineAfter: boolean;
readonly renderWhitespace: boolean; readonly renderWhitespace: boolean;
readonly renderControlCharacters: boolean; readonly renderControlCharacters: boolean;
readonly fontLigatures: boolean;
readonly renderIndentGuides: boolean; readonly renderIndentGuides: boolean;
readonly renderLineHighlight: boolean; readonly renderLineHighlight: boolean;
readonly scrollbar: boolean; readonly scrollbar: boolean;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册