From cd448f74d63ea92cf45645e9644e41c194659be5 Mon Sep 17 00:00:00 2001 From: "Timothy J. Warren" Date: Thu, 29 Feb 2024 13:51:45 -0500 Subject: [PATCH] Fix some issues with search functionality --- justfile | 3 +++ src/common/editor.ts | 9 ++++++--- src/deno/ffi.ts | 5 +---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/justfile b/justfile index b338e7d..e7d7bf3 100644 --- a/justfile +++ b/justfile @@ -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 diff --git a/src/common/editor.ts b/src/common/editor.ts index daae49c..c90afc3 100644 --- a/src/common/editor.ts +++ b/src/common/editor.ts @@ -305,14 +305,17 @@ class Editor { 'Search: %s (Use ESC/Arrows/Enter)', (query: string, key: string) => { if (key === KeyCommand.Enter || key === KeyCommand.Escape) { - this.#document.resetFind(); - return; + if (key === KeyCommand.Escape) { + this.#document.resetFind(); + } + 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); } diff --git a/src/deno/ffi.ts b/src/deno/ffi.ts index f9c2f32..bc2b818 100644 --- a/src/deno/ffi.ts +++ b/src/deno/ffi.ts @@ -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(); - } + cStdLib.close(); closed = true; }