Fix some issues with search functionality
All checks were successful
timw4mail/scroll/pipeline/head This commit looks good

This commit is contained in:
Timothy Warren 2024-02-29 13:51:45 -05:00
parent 85dbd506c6
commit cd448f74d6
3 changed files with 10 additions and 7 deletions

View File

@ -18,6 +18,9 @@ fmt:
# Run tests with all the runtimes
test: deno-test bun-test
# Run all code-quality related tasks
quality: check test
# Clean up any generated files
clean:
rm -rf .deno-cover

View File

@ -305,14 +305,17 @@ class Editor {
'Search: %s (Use ESC/Arrows/Enter)',
(query: string, key: string) => {
if (key === KeyCommand.Enter || key === KeyCommand.Escape) {
if (key === KeyCommand.Escape) {
this.#document.resetFind();
return;
}
return null;
}
if (query !== null && query.length > 0) {
const pos = this.#document.find(query, key);
if (pos !== null) {
this.#cursor = pos;
this.scroll();
} else {
this.setStatusMessage('Not found');
}
@ -322,7 +325,7 @@ class Editor {
// Return to document position before search
// when you cancel the search (press the escape key)
if (query !== null) {
if (query === null) {
this.#cursor = Position.from(savedCursor);
this.#offset = Position.from(savedOffset);
}

View File

@ -42,10 +42,7 @@ const DenoFFI: IFFI = {
getPointer: Deno.UnsafePointer.of,
close: () => {
if (!closed) {
// Closing appears to do bad things on macOS
if (Deno.build.os !== 'darwin') {
cStdLib.close();
}
closed = true;
}