Merge branch 'ilius-PR-find-on-type'
This commit is contained in:
commit
c1e0e1d3b6
3 changed files with 23 additions and 14 deletions
|
@ -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)
|
||||
|
|
|
@ -269,6 +269,7 @@ var defaultCommonSettings = map[string]interface{}{
|
|||
"fastdirty": false,
|
||||
"fileformat": "unix",
|
||||
"filetype": "unknown",
|
||||
"incsearch": true,
|
||||
"ignorecase": true,
|
||||
"indentchar": " ",
|
||||
"keepautoindent": false,
|
||||
|
|
|
@ -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": " ",
|
||||
|
|
Loading…
Reference in a new issue