pieceTreeTextBuffer.ts ×9

Frontier kind: Code frontier

unlabeled · c_091c5cb9d752

349 tests · 40710 LOC · 238 files · introduces 0 tests · 59 LOC · 3 files

Introduces — evidence that enters the hierarchy at this concept

Code
11 ranges59 lines · 3 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
4940 ranges40710 lines · 238 files · Browse complete extent
All tests (intent)
349 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.

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.

3 files ranked by introduced lines: 59 introduced LOC across 11 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer.ts 54 introduced LOC · 9 ranges

Open complete file

318 }
319 }
321 > if (canReduceOperations) {
322 > operations = this._reduceOperations(operations);
323 > }
324 >
325 > // Delta encode operations
326 const reverseRanges = (computeUndoEdits || recordTrimAutoWhitespace ? PieceTreeTextBuffer._getInverseEditRanges(operations) : []);
327 const newTrimAutoWhitespaceCandidates: { lineNumber: number; oldContent: string }[] = [];
328 if (recordTrimAutoWhitespace) {
329 > for (let i = 0; i < operations.length; i++) { pieceTreeTextBuffer.ts
330 > const op = operations[i];
331 > const reverseRange = reverseRanges[i];
332 >
333 > if (op.isAutoWhitespaceEdit && op.range.isEmpty()) {
334 // Record already the future line numbers that might be auto whitespace removal candidates on next edit
335 for (let lineNumber = reverseRange.startLineNumber; lineNumber <= reverseRange.endLineNumber; lineNumber++) {
344 }
345 }
347 > }
348 >
349 > let reverseOperations: IReverseSingleEditOperation[] | null = null;
350 > if (computeUndoEdits) {
351
352 let reverseRangeDeltaOffset = 0;
373 }
374 }
376 >
377 > this._mightContainRTL = mightContainRTL;
378 > this._mightContainUnusualLineTerminators = mightContainUnusualLineTerminators;
379 > this._mightContainNonBasicASCII = mightContainNonBasicASCII;
380 >
381 > const contentChanges = this._doApplyEdits(operations);
382 >
383 > let trimAutoWhitespaceLineNumbers: number[] | null = null;
384 if (recordTrimAutoWhitespace && newTrimAutoWhitespaceCandidates.length > 0) {
385 // sort line numbers auto whitespace removal candidates for next edit descending
404 }
405 }
407 > this._onDidChangeContent.fire();
408 >
409 > return new ApplyEditsResult(
410 > reverseOperations,
411 > contentChanges,
412 > trimAutoWhitespaceLineNumbers
413 > );
414 }
415
419 */
420 private _reduceOperations(operations: IValidatedEditOperation[]): IValidatedEditOperation[] {
421 > if (operations.length < 1000) { pieceTreeTextBuffer.ts
422 > // We know from empirical testing that a thousand edits work fine regardless of their shape.
423 > return operations;
424 > }
425
426 // At one point, due to how events are emitted and how each operation is handled,
430 // Therefore, the strategy is to collapse all the operations into a huge single edit operation
431 return [this._toSingleEditOperation(operations)];
433
434 _toSingleEditOperation(operations: IValidatedEditOperation[]): IValidatedEditOperation {
478
479 private _doApplyEdits(operations: IValidatedEditOperation[]): IInternalModelContentChange[] {
480 > operations.sort(PieceTreeTextBuffer._sortOpsDescending); pieceTreeTextBuffer.ts
481 >
482 > const contentChanges: IInternalModelContentChange[] = [];
483 >
484 > // operations are from bottom to top
485 > for (let i = 0; i < operations.length; i++) {
486 > const op = operations[i];
487 >
488 > const startLineNumber = op.range.startLineNumber;
489 > const startColumn = op.range.startColumn;
490 > const endLineNumber = op.range.endLineNumber;
491 > const endColumn = op.range.endColumn;
492 >
493 > if (startLineNumber === endLineNumber && startColumn === endColumn && op.text.length === 0) {
494 // no-op
495 continue;
515 });
516 }
517 > return contentChanges; pieceTreeTextBuffer.ts
518 > }
519
520 findMatchesLineByLine(searchRange: Range, searchData: SearchData, captureMatches: boolean, limitResultCount: number): FindMatch[] {
src/vs/editor/common/model.ts 4 introduced LOC · 1 range

Open complete file

1598
1599 constructor(
1600 > public readonly reverseEdits: IValidEditOperation[] | null, model.ts
1601 > public readonly changes: IInternalModelContentChange[],
1602 > public readonly trimAutoWhitespaceLineNumbers: number[] | null
1603 > ) { }
1604
1605 }
src/vs/editor/common/model/textModel.ts 1 introduced LOC · 1 range

Open complete file

1598 );
1599 }
1600 > textModel.ts
1601 return (result.reverseEdits === null ? undefined : result.reverseEdits);
1602 }