Skip to content

Commit f685360

Browse files
committed
Add docs to line cache entry items
1 parent 0fcd870 commit f685360

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

addons/xterm-addon-search/src/SearchAddon.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,16 @@ export interface ISearchResult {
2424
size: number;
2525
}
2626

27-
type LineCacheEntry = [lineAsString: string, offsets: number[]];
27+
type LineCacheEntry = [
28+
/**
29+
* The string representation of a line (as opposed to the buffer cell representation).
30+
*/
31+
lineAsString: string,
32+
/**
33+
* The offsets where each line starts when the entry describes a wrapped line.
34+
*/
35+
lineOffsets: number[]
36+
];
2837

2938
const NON_WORD_CHARACTERS = ' ~!@#$%^&*()+`-=[]{}|\\;:"\',./<>?';
3039
const LINES_CACHE_TIME_TO_LIVE = 15 * 1000; // 15 secs
@@ -408,7 +417,7 @@ export class SearchAddon implements ITerminalAddon {
408417
private _translateBufferLineToStringWithWrap(lineIndex: number, trimRight: boolean): LineCacheEntry {
409418
const terminal = this._terminal!;
410419
const strings = [];
411-
const offsets = [0];
420+
const lineOffsets = [0];
412421
let line = terminal.buffer.active.getLine(lineIndex);
413422
while (line) {
414423
const nextLine = terminal.buffer.active.getLine(lineIndex + 1);
@@ -424,14 +433,14 @@ export class SearchAddon implements ITerminalAddon {
424433
}
425434
strings.push(string);
426435
if (lineWrapsToNext) {
427-
offsets.push(offsets[offsets.length - 1] + string.length);
436+
lineOffsets.push(lineOffsets[lineOffsets.length - 1] + string.length);
428437
} else {
429438
break;
430439
}
431440
lineIndex++;
432441
line = nextLine;
433442
}
434-
return [strings.join(''), offsets];
443+
return [strings.join(''), lineOffsets];
435444
}
436445

437446
/**

0 commit comments

Comments
 (0)