Fix some issues with search functionality
timw4mail/scroll/pipeline/head This commit looks good Details

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 # Run tests with all the runtimes
test: deno-test bun-test test: deno-test bun-test
# Run all code-quality related tasks
quality: check test
# Clean up any generated files # Clean up any generated files
clean: clean:
rm -rf .deno-cover rm -rf .deno-cover

View File

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

View File

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