mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-30 14:47:16 +09:00
find: prefill with selection (#2115)
* find: prefill with selection * keep search func - could be used in plugins
This commit is contained in:
@@ -903,7 +903,7 @@ func (h *BufPane) find(useRegex bool) bool {
|
|||||||
h.Relocate()
|
h.Relocate()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
InfoBar.Prompt(prompt, "", "Find", eventCallback, func(resp string, canceled bool) {
|
findCallback := func(resp string, canceled bool) {
|
||||||
// Finished callback
|
// Finished callback
|
||||||
if !canceled {
|
if !canceled {
|
||||||
match, found, err := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex)
|
match, found, err := h.Buf.FindNext(resp, h.Buf.Start(), h.Buf.End(), h.searchOrig, true, useRegex)
|
||||||
@@ -926,8 +926,12 @@ func (h *BufPane) find(useRegex bool) bool {
|
|||||||
h.Cursor.ResetSelection()
|
h.Cursor.ResetSelection()
|
||||||
}
|
}
|
||||||
h.Relocate()
|
h.Relocate()
|
||||||
})
|
}
|
||||||
|
pattern := string(h.Cursor.GetSelection())
|
||||||
|
if eventCallback != nil && pattern != "" {
|
||||||
|
eventCallback(pattern)
|
||||||
|
}
|
||||||
|
InfoBar.Prompt(prompt, pattern, "Find", eventCallback, findCallback)
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user