linesLayout.ts ×46

Frontier kind: Code frontier

unlabeled · c_9d0b1d8eaff7

12 tests · 12960 LOC · 39 files · introduces 0 tests · 279 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
46 ranges279 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
1251 ranges12960 lines · 39 files · Browse complete extent
All tests (intent)
12 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Introduced files, introduced tests, and structurally relevant concept specializationlinesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout 2|occurrence=1 · 0 introduced LOClinesLayout.test|title=E…linesLayout.ts ×3 · 29 introduced LOClinesLayout.ts ×3linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout 1|occurrence=1, linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout Padding|occurrence=1 · 0 introduced LOClinesLayout.test|title=E…linesLayout.ts ×2 · 4 introduced LOClinesLayout.ts ×2linesLayout.ts ×1 · 3 introduced LOClinesLayout.ts ×1linesLayout.ts ×6 · 102 introduced LOClinesLayout.ts ×6linesLayout.ts ×1 · 4 introduced LOClinesLayout.ts ×1linesLayout.ts ×2 · 27 introduced LOClinesLayout.ts ×2linesLayout.ts ×1 · 2 introduced LOClinesLayout.ts ×1linesLayout.ts ×2 · 4 introduced LOClinesLayout.ts ×2linesLayout.ts ×3 · 6 introduced LOClinesLayout.ts ×3linesLayout.ts ×4 · 28 introduced LOClinesLayout.ts ×4linesLayout.ts ×8 · 41 introduced LOClinesLayout.ts ×8linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout changeWhitespaceAfterLineNumber & getFirstWhitespaceIndexAfterLineNumber|occurrence=1 · 0 introduced LOClinesLayout.test|title=E…linesLayout.ts ×7 · 44 introduced LOClinesLayout.ts ×7linesLayout.ts ×1 · 2 introduced LOClinesLayout.ts ×1linesLayout.ts ×2 · 18 introduced LOClinesLayout.ts ×2linesLayout.ts ×1 · 2 introduced LOClinesLayout.ts ×1linesLayout.ts ×1 · 13 introduced LOClinesLayout.ts ×1linesLayout.ts ×10 · 25 introduced LOClinesLayout.ts ×10linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout Bug|occurrence=1 · 0 introduced LOClinesLayout.test|title=E…linesLayout.ts ×1 · 2 introduced LOClinesLayout.ts ×1linesLayout.ts ×1 · 2 introduced LOClinesLayout.ts ×1linesLayout.ts ×3 · 13 introduced LOClinesLayout.ts ×3linesLayout.ts ×3 · 13 introduced LOClinesLayout.ts ×3linesLayout.ts ×2 · 6 introduced LOClinesLayout.ts ×2linesLayout.ts ×1 · 4 introduced LOClinesLayout.ts ×1linesLayout.ts ×2 · 23 introduced LOClinesLayout.ts ×2linesLayout.ts ×2 · 12 introduced LOClinesLayout.ts ×2linesLayout.ts ×1 · 4 introduced LOClinesLayout.ts ×1linesLayout.ts ×13 · 72 introduced LOClinesLayout.ts ×13linesLayout.ts ×1 · 1 introduced LOClinesLayout.ts ×1linesLayout.ts ×3 · 5 introduced LOClinesLayout.ts ×3linesLayout.ts ×3 · 8 introduced LOClinesLayout.ts ×3lineHeights.ts ×24 · 127 introduced LOClineHeights.ts ×24editorOptions.ts ×92 · 6015 introduced LOCeditorOptions.ts ×92contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×3 · 7 introduced LOCcontextkey.ts ×3contextkey.ts ×1 · 3 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 3 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×2 · 3 introduced LOCcontextkey.ts ×2contextkey.ts ×1 · 2 introduced LOCcontextkey.ts ×1contextkey.ts ×1 · 4 introduced LOCcontextkey.ts ×1contextkey.ts ×201 · 796 introduced LOCcontextkey.ts ×201wordHelper.ts ×5 · 70 introduced LOCwordHelper.ts ×5strings.test|title=Strings trimWhitespace|occurrence=1 · 0 introduced LOCstrings.test|title=Strin…strings.ts ×101 · 542 introduced LOCstrings.ts ×101scrollable.ts ×32 · 205 introduced LOCscrollable.ts ×32cancellation.test|title=CancellationToken None|occurrence=1 · 0 introduced LOCcancellation.test|title=…cancellation.ts ×18 · 90 introduced LOCcancellation.ts ×18event.ts ×2 · 4 introduced LOCevent.ts ×2event.ts ×2 · 6 introduced LOCevent.ts ×2event.ts ×93 · 864 introduced LOCevent.ts ×93scanner.ts ×13 · 13 introduced LOCscanner.ts ×13scanner.ts ×3 · 3 introduced LOCscanner.ts ×3scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×1 · 1 introduced LOCscanner.ts ×1scanner.ts ×36 · 181 introduced LOCscanner.ts ×36linkedList.ts ×1 · 2 introduced LOClinkedList.ts ×1linkedList.ts ×3 · 11 introduced LOClinkedList.ts ×3linkedList.ts ×1 · 4 introduced LOClinkedList.ts ×1uri.test|title=URI URI#file, win-speciale|occurrence=1, charCode.test|title=CharCode has good values|occurrence=1, +2 · 0 introduced LOCuri.test|title=URI URI#f…utils.ts ×3 · 9 introduced LOCutils.ts ×3nls.ts ×1 · 1 introduced LOCnls.ts ×1nls.ts ×3 · 9 introduced LOCnls.ts ×3nls.ts ×1 · 1 introduced LOCnls.ts ×1linkedList.ts ×13 · 44 introduced LOClinkedList.ts ×13nls.ts ×6 · 13 introduced LOCnls.ts ×6objects.ts ×13 · 65 introduced LOCobjects.ts ×13instantiation.ts ×5 · 111 introduced LOCinstantiation.ts ×5lifecycle.ts ×2 · 4 introduced LOClifecycle.ts ×2lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×4 · 8 introduced LOClifecycle.ts ×4lifecycle.ts ×6 · 16 introduced LOClifecycle.ts ×6lazy.ts ×1 · 2 introduced LOClazy.ts ×1lazy.ts ×3 · 37 introduced LOClazy.ts ×3lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1lifecycle.ts ×1 · 2 introduced LOClifecycle.ts ×1uint.ts ×2 · 43 introduced LOCuint.ts ×2lifecycle.ts ×1 · 3 introduced LOClifecycle.ts ×1map.ts ×97 · 3334 introduced LOCmap.ts ×97src/vs/base/common/arrays.ts · 949 LOCcommon/arrays.tssrc/vs/base/common/arraysFind.ts · 226 LOCcommon/arraysFind.tssrc/vs/base/common/assert.ts · 91 LOCcommon/assert.tssrc/vs/base/common/cache.ts · 153 LOCcommon/cache.tssrc/vs/base/common/cancellation.ts · 206 LOCcommon/cancellation.tssrc/vs/base/common/charCode.ts · 450 LOCcommon/charCode.tssrc/vs/base/common/collections.ts · 176 LOCcommon/collections.tssrc/vs/base/common/errors.ts · 357 LOCcommon/errors.tssrc/vs/base/common/event.ts · 1964 LOCcommon/event.tssrc/vs/base/common/functional.ts · 32 LOCcommon/functional.tssrc/vs/base/common/iterator.ts · 194 LOCcommon/iterator.tssrc/vs/base/common/lazy.ts · 57 LOCcommon/lazy.tssrc/vs/base/common/lifecycle.ts · 974 LOCcommon/lifecycle.tssrc/vs/base/common/linkedList.ts · 151 LOCcommon/linkedList.tssrc/vs/base/common/map.ts · 1016 LOCcommon/map.tssrc/vs/base/common/marshallingIds.ts · 33 LOCcommon/marshallingIds.tssrc/vs/base/common/objects.ts · 286 LOCcommon/objects.tssrc/vs/base/common/path.ts · 1589 LOCcommon/path.tssrc/vs/base/common/platform.ts · 281 LOCcommon/platform.tssrc/vs/base/common/process.ts · 76 LOCcommon/process.tssrc/vs/base/common/scrollable.ts · 522 LOCcommon/scrollable.tssrc/vs/base/common/stopwatch.ts · 41 LOCcommon/stopwatch.tssrc/vs/base/common/strings.ts · 1413 LOCcommon/strings.tssrc/vs/base/common/types.ts · 410 LOCcommon/types.tssrc/vs/base/common/uint.ts · 59 LOCcommon/uint.tssrc/vs/base/common/uri.ts · 754 LOCcommon/uri.tssrc/vs/base/test/common/utils.ts · 107 LOCcommon/utils.tssrc/vs/editor/common/config/editorOptions.ts · 6891 LOCconfig/editorOptions.tssrc/vs/editor/common/config/editorZoom.ts · 34 LOCconfig/editorZoom.tssrc/vs/editor/common/config/fontInfo.ts · 244 LOCconfig/fontInfo.tssrc/vs/editor/common/core/misc/textModelDefaults.ts · 17 LOCmisc/textModelDefaults.t…src/vs/editor/common/core/wordHelper.ts · 175 LOCcore/wordHelper.tssrc/vs/editor/common/viewLayout/lineHeights.ts · 493 LOCviewLayout/lineHeights.t…src/vs/editor/common/viewLayout/linesLayout.ts · 912 LOCviewLayout/linesLayout.t…src/vs/nls.ts · 244 LOCvs/nls.tssrc/vs/platform/accessibility/common/accessibility.ts · 57 LOCcommon/accessibility.tssrc/vs/platform/contextkey/common/contextkey.ts · 2183 LOCcommon/contextkey.tssrc/vs/platform/contextkey/common/scanner.ts · 384 LOCcommon/scanner.tssrc/vs/platform/instantiation/common/instantiation.ts · 130 LOCcommon/instantiation.tscancellation.test|title=CancellationToken None|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/cancellation.test|title=CancellationToken None|occurrence=1cancellation.test|title=…charCode.test|title=CharCode has good values|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/charCode.test|title=CharCode has good values|occurrence=1charCode.test|title=Char…path.test|title=Paths (Node Implementation) path|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/path.test|title=Paths (Node Implementation) path|occurrence=1path.test|title=Paths (N…strings.test|title=Strings trimWhitespace|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/strings.test|title=Strings trimWhitespace|occurrence=1strings.test|title=Strin…uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI File paths containing apostrophes break URI parsing and cannot be opened #276075|occurrence=1uri.test|title=URI File …uri.test|title=URI URI#file, win-speciale|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/base/test/common/uri.test|title=URI URI#file, win-speciale|occurrence=1uri.test|title=URI URI#f…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout 1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout 1|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout 2|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout 2|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout Bug|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout Bug|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout Padding|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout Padding|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout changeWhitespaceAfterLineNumber & getFirstWhitespaceIndexAfterLineNumber|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout changeWhitespaceAfterLineNumber & getFirstWhitespaceIndexAfterLineNumber|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout findInsertionIndex|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout findInsertionIndex|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getCenteredLineInViewport|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getCenteredLineInViewport|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getLineNumberAtOrAfterVerticalOffset|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getLineNumberAtOrAfterVerticalOffset|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getLinesViewportData 1|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getLinesViewportData 1|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getLinesViewportData 2 & getWhitespaceViewportData|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getLinesViewportData 2 & getWhitespaceViewportData|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getWhitespaceAtVerticalOffset|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout getWhitespaceAtVerticalOffset|occurrence=1linesLayout.test|title=E…linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout|occurrence=1 · introduced test · mocha:v1|namespace=vscode@05c208e9e28d8c1c723fa08f85e2b7a96092e8e5|file=vs/editor/test/common/viewLayout/linesLayout.test|title=Editor ViewLayout - LinesLayout LinesLayout|occurrence=1linesLayout.test|title=E…Focused concept · linesLayout.ts ×46 · 279 introduced LOClinesLayout.ts ×46

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 279 introduced LOC across 46 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/viewLayout/linesLayout.ts 279 introduced LOC · 46 ranges

Open complete file

1 > /*--------------------------------------------------------------------------------------------- linesLayout.ts
2 > * Copyright (c) Microsoft Corporation. All rights reserved.
3 > * Licensed under the MIT License. See License.txt in the project root for license information.
4 > *--------------------------------------------------------------------------------------------*/
5 >
6 > import { IEditorWhitespace, IPartialViewLinesViewportData, ILineHeightChangeAccessor, IViewWhitespaceViewportData, IWhitespaceChangeAccessor } from '../viewModel.js';
7 > import * as strings from '../../../base/common/strings.js';
8 > import { CustomLineHeightData, LineHeightsManager } from './lineHeights.js';
9 >
10 > interface IPendingChange { id: string; newAfterLineNumber: number; newHeight: number }
11 > interface IPendingRemove { id: string }
12 >
13 > class PendingChanges {
14 > private _hasPending: boolean;
15 > private _inserts: EditorWhitespace[];
16 > private _changes: IPendingChange[];
17 > private _removes: IPendingRemove[];
18 >
19 > constructor() {
20 this._hasPending = false;
21 this._inserts = [];
23 this._removes = [];
24 }
26 > public insert(x: EditorWhitespace): void {
27 this._hasPending = true;
28 this._inserts.push(x);
29 }
31 > public change(x: IPendingChange): void {
32 this._hasPending = true;
33 this._changes.push(x);
34 }
36 > public remove(x: IPendingRemove): void {
37 this._hasPending = true;
38 this._removes.push(x);
39 }
41 > public commit(linesLayout: LinesLayout): void {
42 if (!this._hasPending) {
43 return;
55 linesLayout._commitPendingChanges(inserts, changes, removes);
56 }
58 >
59 > export class EditorWhitespace implements IEditorWhitespace {
60 > public id: string;
61 > public afterLineNumber: number;
62 > public ordinal: number;
63 > public height: number;
64 > public minWidth: number;
65 > public prefixSum: number;
66 >
67 > constructor(id: string, afterLineNumber: number, ordinal: number, height: number, minWidth: number) {
68 > this.id = id;
69 > this.afterLineNumber = afterLineNumber;
70 > this.ordinal = ordinal;
71 > this.height = height;
72 > this.minWidth = minWidth;
73 > this.prefixSum = 0;
74 > }
75 > }
76 >
77 > /**
78 > * Layouting of objects that take vertical space (by having a height) and push down other objects.
79 > *
80 > * These objects are basically either text (lines) or spaces between those lines (whitespaces).
81 > * This provides commodity operations for working with lines that contain whitespace that pushes lines lower (vertically).
82 > */
83 > export class LinesLayout {
84 >
85 > private static INSTANCE_COUNT = 0;
86 >
87 > private readonly _instanceId: string;
88 > private readonly _pendingChanges: PendingChanges;
89 > private _lastWhitespaceId: number;
90 > private _arr: EditorWhitespace[];
91 > private _prefixSumValidIndex: number;
92 > private _minWidth: number;
93 > private _lineCount: number;
94 > private _paddingTop: number;
95 > private _paddingBottom: number;
96 > private _lineHeightsManager: LineHeightsManager;
97 >
98 > constructor(lineCount: number, defaultLineHeight: number, paddingTop: number, paddingBottom: number, customLineHeightData: CustomLineHeightData[]) {
99 this._instanceId = strings.singleLetterHash(++LinesLayout.INSTANCE_COUNT);
100 this._pendingChanges = new PendingChanges();
108 this._lineHeightsManager = new LineHeightsManager(defaultLineHeight, customLineHeightData);
109 }
111 > /**
112 > * Find the insertion index for a new value inside a sorted array of values.
113 > * If the value is already present in the sorted array, the insertion index will be after the already existing value.
114 > */
115 > public static findInsertionIndex(arr: EditorWhitespace[], afterLineNumber: number, ordinal: number): number {
116 > let low = 0;
117 > let high = arr.length;
118 >
119 > while (low < high) {
120 const mid = ((low + high) >>> 1);
121
132 }
133 }
135 > return low;
136 > }
137 >
138 > /**
139 > * Change the height of a line in pixels.
140 > */
141 > public setDefaultLineHeight(lineHeight: number): void {
142 this._lineHeightsManager.defaultLineHeight = lineHeight;
143 }
145 > /**
146 > * Changes the padding used to calculate vertical offsets.
147 > */
148 > public setPadding(paddingTop: number, paddingBottom: number): void {
149 this._paddingTop = paddingTop;
150 this._paddingBottom = paddingBottom;
151 }
153 > /**
154 > * Set the number of lines.
155 > *
156 > * @param lineCount New number of lines.
157 > */
158 > public onFlushed(lineCount: number, customLineHeightData: CustomLineHeightData[]): void {
159 this._lineCount = lineCount;
160 this._lineHeightsManager = new LineHeightsManager(this._lineHeightsManager.defaultLineHeight, customLineHeightData);
161 }
163 > public changeLineHeights(callback: (accessor: ILineHeightChangeAccessor) => void): boolean {
164 let hadAChange = false;
165 const accessor: ILineHeightChangeAccessor = {
176 return hadAChange;
177 }
179 > public changeWhitespace(callback: (accessor: IWhitespaceChangeAccessor) => void): boolean {
180 let hadAChange = false;
181 try {
208 return hadAChange;
209 }
211 > public _commitPendingChanges(inserts: EditorWhitespace[], changes: IPendingChange[], removes: IPendingRemove[]): void {
212 if (inserts.length > 0 || removes.length > 0) {
213 this._minWidth = -1; /* marker for not being computed */
271 this._prefixSumValidIndex = -1;
272 }
274 > private _insertWhitespace(whitespace: EditorWhitespace): void {
275 const insertIndex = LinesLayout.findInsertionIndex(this._arr, whitespace.afterLineNumber, whitespace.ordinal);
276 this._arr.splice(insertIndex, 0, whitespace);
277 this._prefixSumValidIndex = Math.min(this._prefixSumValidIndex, insertIndex - 1);
278 }
280 > private _findWhitespaceIndex(id: string): number {
281 const arr = this._arr;
282 for (let i = 0, len = arr.length; i < len; i++) {
287 return -1;
288 }
290 > private _changeOneWhitespace(id: string, newAfterLineNumber: number, newHeight: number): void {
291 const index = this._findWhitespaceIndex(id);
292 if (index === -1) {
312 }
313 }
315 > private _removeWhitespace(removeIndex: number): void {
316 this._arr.splice(removeIndex, 1);
317 this._prefixSumValidIndex = Math.min(this._prefixSumValidIndex, removeIndex - 1);
318 }
320 > /**
321 > * Notify the layouter that lines have been deleted (a continuous zone of lines).
322 > *
323 > * @param fromLineNumber The line number at which the deletion started, inclusive
324 > * @param toLineNumber The line number at which the deletion ended, inclusive
325 > */
326 > public onLinesDeleted(fromLineNumber: number, toLineNumber: number): void {
327 fromLineNumber = fromLineNumber | 0;
328 toLineNumber = toLineNumber | 0;
344 this._lineHeightsManager.onLinesDeleted(fromLineNumber, toLineNumber);
345 }
347 > /**
348 > * Notify the layouter that lines have been inserted (a continuous zone of lines).
349 > *
350 > * @param fromLineNumber The line number at which the insertion started, inclusive
351 > * @param toLineNumber The line number at which the insertion ended, inclusive.
352 > */
353 > public onLinesInserted(fromLineNumber: number, toLineNumber: number): void {
354 fromLineNumber = fromLineNumber | 0;
355 toLineNumber = toLineNumber | 0;
365 this._lineHeightsManager.onLinesInserted(fromLineNumber, toLineNumber);
366 }
368 > /**
369 > * Get the sum of all the whitespaces.
370 > */
371 > public getWhitespacesTotalHeight(): number {
372 if (this._arr.length === 0) {
373 return 0;
375 return this.getWhitespacesAccumulatedHeight(this._arr.length - 1);
376 }
378 > /**
379 > * Return the sum of the heights of the whitespaces at [0..index].
380 > * This includes the whitespace at `index`.
381 > *
382 > * @param index The index of the whitespace.
383 > * @return The sum of the heights of all whitespaces before the one at `index`, including the one at `index`.
384 > */
385 > public getWhitespacesAccumulatedHeight(index: number): number {
386 index = index | 0;
387
398 return this._arr[index].prefixSum;
399 }
401 > /**
402 > * Get the sum of heights for all objects.
403 > *
404 > * @return The sum of heights for all objects.
405 > */
406 > public getLinesTotalHeight(): number {
407 const linesHeight = this._lineHeightsManager.getAccumulatedLineHeightsIncludingLineNumber(this._lineCount);
408 const whitespacesHeight = this.getWhitespacesTotalHeight();
410 return linesHeight + whitespacesHeight + this._paddingTop + this._paddingBottom;
411 }
413 > /**
414 > * Returns the accumulated height of whitespaces before the given line number.
415 > *
416 > * @param lineNumber The line number
417 > */
418 > public getWhitespaceAccumulatedHeightBeforeLineNumber(lineNumber: number): number {
419 lineNumber = lineNumber | 0;
420
427 return this.getWhitespacesAccumulatedHeight(lastWhitespaceBeforeLineNumber);
428 }
430 > private _findLastWhitespaceBeforeLineNumber(lineNumber: number): number {
431 lineNumber = lineNumber | 0;
432
454 return -1;
455 }
457 > private _findFirstWhitespaceAfterLineNumber(lineNumber: number): number {
458 lineNumber = lineNumber | 0;
459
467 return -1;
468 }
470 > /**
471 > * Find the index of the first whitespace which has `afterLineNumber` >= `lineNumber`.
472 > * @return The index of the first whitespace with `afterLineNumber` >= `lineNumber` or -1 if no whitespace is found.
473 > */
474 > public getFirstWhitespaceIndexAfterLineNumber(lineNumber: number): number {
475 lineNumber = lineNumber | 0;
476
477 return this._findFirstWhitespaceAfterLineNumber(lineNumber);
478 }
480 > /**
481 > * Get the vertical offset (the sum of heights for all objects above) a certain line number.
482 > *
483 > * @param lineNumber The line number
484 > * @return The sum of heights for all objects above `lineNumber`.
485 > */
486 > public getVerticalOffsetForLineNumber(lineNumber: number, includeViewZones = false): number {
487 lineNumber = lineNumber | 0;
488
498 return previousLinesHeight + previousWhitespacesHeight + this._paddingTop;
499 }
501 > public getLineHeightForLineNumber(lineNumber: number): number {
502 return this._lineHeightsManager.heightForLineNumber(lineNumber);
503 }
505 > /**
506 > * Get the vertical offset (the sum of heights for all objects above) a certain line number and also the line height of the line.
507 > *
508 > * @param lineNumber The line number
509 > * @return The sum of heights for all objects above `lineNumber`.
510 > */
511 > public getVerticalOffsetAfterLineNumber(lineNumber: number, includeViewZones = false): number {
512 lineNumber = lineNumber | 0;
513 const previousLinesHeight = this._lineHeightsManager.getAccumulatedLineHeightsIncludingLineNumber(lineNumber);
515 return previousLinesHeight + previousWhitespacesHeight + this._paddingTop;
516 }
518 > /**
519 > * Returns if there is any whitespace in the document.
520 > */
521 > public hasWhitespace(): boolean {
522 return this.getWhitespacesCount() > 0;
523 }
525 > /**
526 > * The maximum min width for all whitespaces.
527 > */
528 > public getWhitespaceMinWidth(): number {
529 if (this._minWidth === -1) {
530 let minWidth = 0;
536 return this._minWidth;
537 }
539 > /**
540 > * Check if `verticalOffset` is below all lines.
541 > */
542 > public isAfterLines(verticalOffset: number): boolean {
543 const totalHeight = this.getLinesTotalHeight();
544 return verticalOffset > totalHeight;
545 }
547 > public isInTopPadding(verticalOffset: number): boolean {
548 if (this._paddingTop === 0) {
549 return false;
551 return (verticalOffset < this._paddingTop);
552 }
554 > public isInBottomPadding(verticalOffset: number): boolean {
555 if (this._paddingBottom === 0) {
556 return false;
559 return (verticalOffset >= totalHeight - this._paddingBottom);
560 }
562 > /**
563 > * Find the first line number that is at or after vertical offset `verticalOffset`.
564 > * i.e. if getVerticalOffsetForLine(line) is x and getVerticalOffsetForLine(line + 1) is y, then
565 > * getLineNumberAtOrAfterVerticalOffset(i) = line, x <= i < y.
566 > *
567 > * @param verticalOffset The vertical offset to search at.
568 > * @return The line number at or after vertical offset `verticalOffset`.
569 > */
570 > public getLineNumberAtOrAfterVerticalOffset(verticalOffset: number): number {
571 verticalOffset = verticalOffset | 0;
572
603 return minLineNumber;
604 }
606 > /**
607 > * Get all the lines and their relative vertical offsets that are positioned between `verticalOffset1` and `verticalOffset2`.
608 > *
609 > * @param verticalOffset1 The beginning of the viewport.
610 > * @param verticalOffset2 The end of the viewport.
611 > * @return A structure describing the lines positioned between `verticalOffset1` and `verticalOffset2`.
612 > */
613 > public getLinesViewportData(verticalOffset1: number, verticalOffset2: number): IPartialViewLinesViewportData {
614 verticalOffset1 = verticalOffset1 | 0;
615 verticalOffset2 = verticalOffset2 | 0;
728 };
729 }
731 > public getVerticalOffsetForWhitespaceIndex(whitespaceIndex: number): number {
732 whitespaceIndex = whitespaceIndex | 0;
733
749 return previousLinesHeight + previousWhitespacesHeight + this._paddingTop;
750 }
752 > public getWhitespaceIndexAtOrAfterVerticallOffset(verticalOffset: number): number {
753 verticalOffset = verticalOffset | 0;
754
786 return minWhitespaceIndex;
787 }
789 > /**
790 > * Get exactly the whitespace that is layouted at `verticalOffset`.
791 > *
792 > * @param verticalOffset The vertical offset.
793 > * @return Precisely the whitespace that is layouted at `verticaloffset` or null.
794 > */
795 > public getWhitespaceAtVerticalOffset(verticalOffset: number): IViewWhitespaceViewportData | null {
796 verticalOffset = verticalOffset | 0;
797
823 };
824 }
826 > /**
827 > * Get a list of whitespaces that are positioned between `verticalOffset1` and `verticalOffset2`.
828 > *
829 > * @param verticalOffset1 The beginning of the viewport.
830 > * @param verticalOffset2 The end of the viewport.
831 > * @return An array with all the whitespaces in the viewport. If no whitespace is in viewport, the array is empty.
832 > */
833 > public getWhitespaceViewportData(verticalOffset1: number, verticalOffset2: number): IViewWhitespaceViewportData[] {
834 verticalOffset1 = verticalOffset1 | 0;
835 verticalOffset2 = verticalOffset2 | 0;
860 return result;
861 }
863 > /**
864 > * Get all whitespaces.
865 > */
866 > public getWhitespaces(): IEditorWhitespace[] {
867 return this._arr.slice(0);
868 }
870 > /**
871 > * The number of whitespaces.
872 > */
873 > public getWhitespacesCount(): number {
874 return this._arr.length;
875 }
877 > /**
878 > * Get the `id` for whitespace at index `index`.
879 > *
880 > * @param index The index of the whitespace.
881 > * @return `id` of whitespace at `index`.
882 > */
883 > public getIdForWhitespaceIndex(index: number): string {
884 index = index | 0;
885
886 return this._arr[index].id;
887 }
889 > /**
890 > * Get the `afterLineNumber` for whitespace at index `index`.
891 > *
892 > * @param index The index of the whitespace.
893 > * @return `afterLineNumber` of whitespace at `index`.
894 > */
895 > public getAfterLineNumberForWhitespaceIndex(index: number): number {
896 index = index | 0;
897
898 return this._arr[index].afterLineNumber;
899 }
901 > /**
902 > * Get the `height` for whitespace at index `index`.
903 > *
904 > * @param index The index of the whitespace.
905 > * @return `height` of whitespace at `index`.
906 > */
907 > public getHeightForWhitespaceIndex(index: number): number {
908 index = index | 0;
909
910 return this._arr[index].height;
911 }
912 > } linesLayout.ts