Merge pull request #8332 from Clem-Fern/fix#8297

This commit is contained in:
Eugene 2023-04-28 22:54:56 +02:00 committed by GitHub
commit fe6836d996
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,6 +69,7 @@ export class XTermFrontend extends Frontend {
private resizeHandler: () => void private resizeHandler: () => void
private configuredTheme: ITheme = {} private configuredTheme: ITheme = {}
private copyOnSelect = false private copyOnSelect = false
private preventNextOnSelectionChangeEvent = false
private search = new SearchAddon() private search = new SearchAddon()
private searchState: SearchState = { resultCount: 0 } private searchState: SearchState = { resultCount: 0 }
private fitAddon = new FitAddon() private fitAddon = new FitAddon()
@ -116,8 +117,11 @@ export class XTermFrontend extends Frontend {
this.title.next(title) this.title.next(title)
}) })
this.xterm.onSelectionChange(() => { this.xterm.onSelectionChange(() => {
if (this.copyOnSelect && this.getSelection()) { if (this.getSelection()) {
this.copySelection() if (this.copyOnSelect && !this.preventNextOnSelectionChangeEvent) {
this.copySelection()
}
this.preventNextOnSelectionChangeEvent = false
} }
}) })
this.xterm.onBell(() => { this.xterm.onBell(() => {
@ -444,12 +448,18 @@ export class XTermFrontend extends Frontend {
} }
findNext (term: string, searchOptions?: SearchOptions): SearchState { findNext (term: string, searchOptions?: SearchOptions): SearchState {
if (this.copyOnSelect) {
this.preventNextOnSelectionChangeEvent = true
}
return this.wrapSearchResult( return this.wrapSearchResult(
this.search.findNext(term, this.getSearchOptions(searchOptions)), this.search.findNext(term, this.getSearchOptions(searchOptions)),
) )
} }
findPrevious (term: string, searchOptions?: SearchOptions): SearchState { findPrevious (term: string, searchOptions?: SearchOptions): SearchState {
if (this.copyOnSelect) {
this.preventNextOnSelectionChangeEvent = true
}
return this.wrapSearchResult( return this.wrapSearchResult(
this.search.findPrevious(term, this.getSearchOptions(searchOptions)), this.search.findPrevious(term, this.getSearchOptions(searchOptions)),
) )