diff --git a/internal/action/actions.go b/internal/action/actions.go index ce9f9d80..1640ff07 100644 --- a/internal/action/actions.go +++ b/internal/action/actions.go @@ -847,21 +847,24 @@ func (h *BufPane) find(useRegex bool) bool { if useRegex { prompt = "Find (regex): " } - InfoBar.Prompt(prompt, "", "Find", func(resp string) { - // Event callback - match, found, _ := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex) - if found { - h.Cursor.SetSelectionStart(match[0]) - h.Cursor.SetSelectionEnd(match[1]) - h.Cursor.OrigSelection[0] = h.Cursor.CurSelection[0] - h.Cursor.OrigSelection[1] = h.Cursor.CurSelection[1] - h.Cursor.GotoLoc(match[1]) - } else { - h.Cursor.GotoLoc(h.searchOrig) - h.Cursor.ResetSelection() + var eventCallback func(resp string) + if h.Buf.Settings["incsearch"].(bool) { + eventCallback = func(resp string) { + match, found, _ := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex) + if found { + h.Cursor.SetSelectionStart(match[0]) + h.Cursor.SetSelectionEnd(match[1]) + h.Cursor.OrigSelection[0] = h.Cursor.CurSelection[0] + h.Cursor.OrigSelection[1] = h.Cursor.CurSelection[1] + h.Cursor.GotoLoc(match[1]) + } else { + h.Cursor.GotoLoc(h.searchOrig) + h.Cursor.ResetSelection() + } + h.Relocate() } - h.Relocate() - }, func(resp string, canceled bool) { + } + InfoBar.Prompt(prompt, "", "Find", eventCallback, func(resp string, canceled bool) { // Finished callback if !canceled { match, found, err := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex) diff --git a/internal/config/settings.go b/internal/config/settings.go index 9b000cbe..966abb15 100644 --- a/internal/config/settings.go +++ b/internal/config/settings.go @@ -269,6 +269,7 @@ var defaultCommonSettings = map[string]interface{}{ "fastdirty": false, "fileformat": "unix", "filetype": "unknown", + "incsearch": true, "ignorecase": true, "indentchar": " ", "keepautoindent": false, diff --git a/runtime/help/options.md b/runtime/help/options.md index 36341b8a..3805de7f 100644 --- a/runtime/help/options.md +++ b/runtime/help/options.md @@ -159,6 +159,10 @@ Here are the available options: default value: `unknown`. This will be automatically overridden depending on the file you open. +* `incsearch`: enable incremental search in "Find" prompt (matching as you type). + + default value: `true` + * `ignorecase`: perform case-insensitive searches. default value: `true` @@ -423,6 +427,7 @@ so that you can see what the formatting should look like. "fastdirty": false, "fileformat": "unix", "filetype": "unknown", + "incsearch": true, "ftoptions": true, "ignorecase": false, "indentchar": " ",