editorWebWorker.ts ×11

Frontier kind: Code frontier

unlabeled · c_8e450e7aa9a1

5 tests · 18962 LOC · 91 files · introduces 0 tests · 67 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges67 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
2079 ranges18962 lines · 91 files · Browse complete extent
All tests (intent)
5 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.

2 files ranked by introduced lines: 67 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/services/editorWebWorker.ts 65 introduced LOC · 11 ranges

Open complete file

299
300 public $computeHumanReadableDiff(modelUrl: string, edits: TextEdit[], options: ILinesDiffComputerOptions): TextEdit[] {
301 > const model = this._getModel(modelUrl); editorWebWorker.ts
302 > if (!model) {
303 return edits;
304 }
306 > const result: TextEdit[] = [];
307 > let lastEol: EndOfLineSequence | undefined = undefined;
308 >
309 > edits = edits.slice(0).sort((a, b) => {
310 if (a.range && b.range) {
311 return Range.compareRangesUsingStarts(a.range, b.range);
315 const bRng = b.range ? 0 : 1;
316 return aRng - bRng;
317 > }); editorWebWorker.ts
318 >
319 > for (let { range, text, eol } of edits) {
320 >
321 > if (typeof eol === 'number') {
322 lastEol = eol;
323 }
325 > if (Range.isEmpty(range) && !text) {
326 // empty change
327 continue;
328 }
330 > const original = model.getValueInRange(range);
331 > text = text.replace(/\r\n|\n|\r/g, model.eol);
332 >
333 > if (original === text) {
334 // noop
335 continue;
336 }
338 > // make sure diff won't take too long
339 > if (Math.max(text.length, original.length) > EditorWorker._diffLimit) {
340 result.push({ range, text });
341 continue;
342 }
344 > // compute diff between original and edit.text
345 >
346 > const originalLines = original.split(/\r\n|\n|\r/);
347 > const modifiedLines = text.split(/\r\n|\n|\r/);
348 >
349 > const diff = linesDiffComputers.getDefault().computeDiff(originalLines, modifiedLines, options);
350 >
351 > const start = Range.lift(range).getStartPosition();
352 >
353 > function addPositions(pos1: Position, pos2: Position): Position {
354 > return new Position(pos1.lineNumber + pos2.lineNumber - 1, pos2.lineNumber === 1 ? pos1.column + pos2.column - 1 : pos2.column);
355 > }
356 >
357 > function getText(lines: string[], range: Range): string[] {
358 > const result: string[] = [];
359 > for (let i = range.startLineNumber; i <= range.endLineNumber; i++) {
360 > const line = lines[i - 1];
361 > if (i === range.startLineNumber && i === range.endLineNumber) {
362 result.push(line.substring(range.startColumn - 1, range.endColumn - 1));
363 > } else if (i === range.startLineNumber) { editorWebWorker.ts
364 result.push(line.substring(range.startColumn - 1));
365 } else if (i === range.endLineNumber) {
368 result.push(line);
369 }
371 > return result;
372 > }
373 >
374 > for (const c of diff.changes) {
375 > if (c.innerChanges) {
376 > for (const x of c.innerChanges) {
377 > result.push({
378 > range: Range.fromPositions(
379 > addPositions(start, x.originalRange.getStartPosition()),
380 > addPositions(start, x.originalRange.getEndPosition())
381 > ),
382 > text: getText(modifiedLines, x.modifiedRange).join(model.eol)
383 > });
384 > }
385 > } else {
386 throw new BugIndicatingError('The experimental diff algorithm always produces inner changes');
387 }
389 > }
390 >
391 > if (typeof lastEol === 'number') {
392 result.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });
393 }
395 > return result;
396 > }
397
398 // ---- END minimal edits ---------------------------------------------------------------
src/vs/editor/common/services/textModelSync/textModelSync.impl.ts 2 introduced LOC · 1 range

Open complete file

182
183 public getValue(): string {
184 > return this.getText(); textModelSync.impl.ts
185 > }
186
187 public findMatches(regex: RegExp): RegExpMatchArray[] {