mirror of
https://github.com/TriliumNext/Notes.git
synced 2025-07-27 18:12:29 +08:00
fix(code/find): clean up search
This commit is contained in:
parent
da6cb71c6a
commit
77fe100591
@ -51,29 +51,7 @@ export default class FindInCode {
|
|||||||
|
|
||||||
async findBoxClosed(totalFound: number, currentFound: number) {
|
async findBoxClosed(totalFound: number, currentFound: number) {
|
||||||
const codeEditor = await this.getCodeEditor();
|
const codeEditor = await this.getCodeEditor();
|
||||||
|
codeEditor?.cleanSearch();
|
||||||
if (codeEditor && totalFound > 0) {
|
|
||||||
const doc = codeEditor.doc;
|
|
||||||
const pos = this.findResult?.[currentFound].find();
|
|
||||||
// Note setting the selection sets the cursor to
|
|
||||||
// the end of the selection and scrolls it into
|
|
||||||
// view
|
|
||||||
if (pos) {
|
|
||||||
doc.setSelection(pos.from, pos.to);
|
|
||||||
}
|
|
||||||
// Clear all markers
|
|
||||||
codeEditor.operation(() => {
|
|
||||||
if (!this.findResult) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (let i = 0; i < this.findResult.length; ++i) {
|
|
||||||
let marker = this.findResult[i];
|
|
||||||
marker.clear();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.findResult = null;
|
|
||||||
|
|
||||||
codeEditor?.focus();
|
codeEditor?.focus();
|
||||||
}
|
}
|
||||||
async replace(replaceText: string) {
|
async replace(replaceText: string) {
|
||||||
|
@ -194,6 +194,15 @@ export default class CodeMirror extends EditorView {
|
|||||||
this.searchPlugin?.scrollToMatch(nextFound);
|
this.searchPlugin?.scrollToMatch(nextFound);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cleanSearch() {
|
||||||
|
if (this.searchPlugin) {
|
||||||
|
this.dispatch({
|
||||||
|
effects: this.searchHighlightCompartment.reconfigure([])
|
||||||
|
});
|
||||||
|
this.searchPlugin = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async setMimeType(mime: string) {
|
async setMimeType(mime: string) {
|
||||||
let newExtension: Extension[] = [];
|
let newExtension: Extension[] = [];
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user