add focus hack, still can't get result count to show

This commit is contained in:
Evan Simkowitz 2024-12-29 15:52:21 -05:00
parent 5a90debb2e
commit 9453f628a9
No known key found for this signature in database
2 changed files with 13 additions and 7 deletions

View File

@ -363,6 +363,10 @@ class TermViewModel implements ViewModel {
}
giveFocus(): boolean {
if (this.searchAtoms && globalStore.get(this.searchAtoms.isOpenAtom)) {
console.log("search is open, not giving focus");
return true;
}
let termMode = globalStore.get(this.termMode);
if (termMode == "term") {
if (this.termRef?.current?.terminal) {
@ -840,11 +844,6 @@ const TerminalView = ({ blockId, model }: TerminalViewProps) => {
useWebGl: !termSettings?.["term:disablewebgl"],
}
);
termWrap.onSearchResultsDidChange = (results) => {
console.log("search results", results);
globalStore.set(searchProps.numResultsAtom, results.resultCount);
globalStore.set(searchProps.indexAtom, results.resultIndex);
};
(window as any).term = termWrap;
model.termRef.current = termWrap;
const rszObs = new ResizeObserver(() => {

View File

@ -154,8 +154,8 @@ export class TermWrap {
}
})
);
if (this.onSearchResultsDidChange)
this.searchAddon.onDidChangeResults(this.onSearchResultsDidChange.bind(this));
this.searchAddon.onDidChangeResults(this.searchResultsDidChange.bind(this));
this.mainFileSubject = getFileSubject(this.blockId, TermFileName);
this.mainFileSubject.subscribe(this.handleNewFileSubjectData.bind(this));
try {
@ -310,4 +310,11 @@ export class TermWrap {
search(search: string) {
this.searchAddon.findNext(search);
}
searchResultsDidChange(result: { resultIndex: number; resultCount: number }) {
console.log("search results changed", result);
if (this.onSearchResultsDidChange) {
this.onSearchResultsDidChange(result);
}
}
}