Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show all matches when searching #3698

Merged
merged 63 commits into from
Mar 22, 2022
Merged
Changes from 1 commit
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
60c11e8
start work
meganrogge Mar 11, 2022
9657442
get it to sort of work
meganrogge Mar 11, 2022
fa4479c
use decoration width, find all and select next
meganrogge Mar 11, 2022
372b6b6
set incremental search to false
meganrogge Mar 11, 2022
da2c59d
remove unused variable
meganrogge Mar 11, 2022
453cb00
use a class
meganrogge Mar 11, 2022
e7bbc41
start at cursor position and mandate a width gt 0
meganrogge Mar 11, 2022
b4de278
hide decorations >= bufferService rows
meganrogge Mar 11, 2022
f678f08
merge
meganrogge Mar 16, 2022
1bab173
fix problems
meganrogge Mar 16, 2022
40b8854
rm bad decoration service
meganrogge Mar 16, 2022
05eb12e
start work on selection color
meganrogge Mar 16, 2022
1939906
Merge branch 'xtermjs:master' into findAll
meganrogge Mar 16, 2022
26f8fce
update color when select next happens
meganrogge Mar 16, 2022
90f64ba
get it to work in the demo
meganrogge Mar 17, 2022
c2145d5
on dispose, clear the canvas at that position
meganrogge Mar 17, 2022
de56d04
return decoration from show result
meganrogge Mar 17, 2022
9bc5090
use a map
meganrogge Mar 18, 2022
c8dc679
Merge branch 'master' into findAll
meganrogge Mar 18, 2022
a1468d0
use start row and col
meganrogge Mar 18, 2022
6c4f8b4
append to results
meganrogge Mar 18, 2022
47ec313
support colors
meganrogge Mar 18, 2022
01fd148
clean up
meganrogge Mar 18, 2022
d2913d6
Merge branch 'master' into findAll
meganrogge Mar 18, 2022
8e68c67
applyStyles
meganrogge Mar 18, 2022
66dcd16
clean up jsdoc
meganrogge Mar 18, 2022
15c2432
jsdoc
meganrogge Mar 18, 2022
85683a4
add to col, not row
meganrogge Mar 18, 2022
dd50378
Update css/xterm.css
meganrogge Mar 18, 2022
8328fca
track disposable
meganrogge Mar 18, 2022
61c2ca7
Metrge branch 'findAll' of https://github.com/meganrogge/xterm.js int…
meganrogge Mar 18, 2022
fef30bd
revert row register marker changes
meganrogge Mar 18, 2022
61e5c10
pull apart and refactor findNext
meganrogge Mar 18, 2022
e79c21d
get it to work for previous too
meganrogge Mar 18, 2022
a0aae62
get rid of start col end col
meganrogge Mar 18, 2022
8225ecd
refactor from highlightAllMatches -> decorations
meganrogge Mar 21, 2022
12a999d
get rid of start row/col code
meganrogge Mar 21, 2022
bec4cb3
set data changed to false if true
meganrogge Mar 21, 2022
8ff34a6
update decorations dynamically when the buffer changes
meganrogge Mar 21, 2022
1098173
use set timeout
meganrogge Mar 21, 2022
faa3769
Merge branch 'master' into findAll
meganrogge Mar 21, 2022
97e4af3
only highlight all matches when decorations are requested
meganrogge Mar 21, 2022
b9331ec
Merge branch 'findAll' of https://github.com/meganrogge/xterm.js into…
meganrogge Mar 21, 2022
4cea6b3
revert a breaking change
meganrogge Mar 21, 2022
64d5af3
Update addons/xterm-addon-search/src/SearchAddon.ts
meganrogge Mar 21, 2022
e8aa4eb
IDecorationColor -> ISearchDecorationOptions
meganrogge Mar 21, 2022
90dca7d
Merge branch 'findAll' of https://github.com/meganrogge/xterm.js into…
meganrogge Mar 21, 2022
7a502c6
use const enum
meganrogge Mar 21, 2022
fefdd8a
clearDecorations
meganrogge Mar 21, 2022
866ee23
add disposeDecorations helper
meganrogge Mar 21, 2022
4645ef7
refactor
meganrogge Mar 21, 2022
7f131aa
fix error
meganrogge Mar 21, 2022
7a70db7
Fix API indentation
Tyriar Mar 21, 2022
09d1a01
Add ISearchDecorationOptions to the d.ts
Tyriar Mar 21, 2022
ef3695f
Move setting opacity into js
Tyriar Mar 21, 2022
87dd275
Undo change to Terminal.ts
Tyriar Mar 21, 2022
efda0e7
Fix indentation properly this time
Tyriar Mar 21, 2022
fe530d9
Ensure marker is disposed when decoration is
Tyriar Mar 21, 2022
23076ba
Fix duplicate decorations getting created
Tyriar Mar 21, 2022
f9deb2f
Don't set overview ruler width when using find
Tyriar Mar 21, 2022
6ef1bdd
Debounce onData listener
Tyriar Mar 21, 2022
b39477d
Fix full decorations
Tyriar Mar 21, 2022
43a014e
Fix decoration lifecycle issues
Tyriar Mar 21, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
start work on selection color
meganrogge committed Mar 16, 2022

Verified

This commit was signed with the committer’s verified signature.
commit 05eb12e6dd051c7c845e524a6d2b05e16ade2f4b
24 changes: 17 additions & 7 deletions addons/xterm-addon-search/src/SearchAddon.ts
Original file line number Diff line number Diff line change
@@ -44,6 +44,7 @@ export class SearchAddon implements ITerminalAddon {
private _result: ISearchResult | undefined;
private _reset: boolean = false;
private _cachedSearchTerm: string | undefined;
private _cachedResults: ISearchResult[] = [];
/**
* translateBufferLineToStringWithWrap is a fairly expensive call.
* We memoize the calls into an array that has a time based ttl.
@@ -81,6 +82,11 @@ export class SearchAddon implements ITerminalAddon {
}

if (!this._reset && term === this._cachedSearchTerm) {
// this._resultDecorations.forEach(d => d.dispose());
// this._resultDecorations = [];
// for (const decoration of this._cachedResults) {
// this._showResultDecoration(decoration);
// }
return this.findNext(term, searchOptions);
}
this._reset = false;
@@ -89,26 +95,25 @@ export class SearchAddon implements ITerminalAddon {
// new search, clear out the old decorations
this._resultDecorations.forEach(d => d.dispose());
this._resultDecorations = [];
const results: ISearchResult[] = [];
searchOptions = searchOptions || {};
searchOptions.incremental = false;
let found = this.findNext(term, searchOptions);
while (found && !results.find(r => r?.col === this._result?.col && r?.row === this._result?.row)) {
while (found && !this._cachedResults.find(r => r?.col === this._result?.col && r?.row === this._result?.row)) {
if (this._result) {
results.push(this._result);
this._cachedResults.push(this._result);
}
found = this.findNext(term, searchOptions);
}

for (const result of results) {
for (const result of this._cachedResults) {
if (result) {
const resultDecoration = this._showResultDecoration(result);
if (resultDecoration) {
this._resultDecorations.push(resultDecoration);
}
}
}
if (results.length > 0) {
if (this._cachedResults.length > 0) {
this._cachedSearchTerm = term;
}
return true;
@@ -517,6 +522,10 @@ export class SearchAddon implements ITerminalAddon {
return false;
}
terminal.select(result.col, result.row, result.size);
const marker = terminal.registerMarker(undefined, result.row);
if (marker) {
terminal.registerDecoration({ marker, overviewRulerOptions: { color: 'yellow' } });
}
// If it is not in the viewport then we scroll else it just gets selected
if (result.row >= (terminal.buffer.active.viewportY + terminal.rows) || result.row < terminal.buffer.active.viewportY) {
let scroll = result.row - terminal.buffer.active.viewportY;
@@ -537,9 +546,10 @@ export class SearchAddon implements ITerminalAddon {
if (!marker) {
return undefined;
}
const findResultDecoration = terminal.registerDecoration({ marker, overviewRulerOptions: { color: 'yellow' } });
terminal.options.overviewRulerWidth = 10;
const findResultDecoration = terminal.registerDecoration({ marker, overviewRulerOptions: { color: 'blue' } });
findResultDecoration?.onRender((e) => {
if (!e.classList.contains('xterm-find-result-decoration') && result.term.length && e.clientWidth > 0) {
if (!e.classList.contains('xterm-find-result-decoration') && result.term.length && e.clientWidth > 0 && !e.classList.contains('xterm-decoration-overview-ruler')) {
e.classList.add('xterm-find-result-decoration');
// decoration's clientWidth = actualCellWidth
e.style.left = `${e.clientWidth * result.col}px`;
2 changes: 1 addition & 1 deletion css/xterm.css
Original file line number Diff line number Diff line change
@@ -180,7 +180,7 @@
}

.xterm-find-result-decoration {
background-color: yellow;
background-color: blue;
opacity: 60%;
meganrogge marked this conversation as resolved.
Show resolved Hide resolved
}
.xterm-decoration-overview-ruler {