Relocate during replace

Fixes #1587
This commit is contained in:
Zachary Yedidia 2020-03-24 11:33:52 -04:00
parent c76a973877
commit 60c8c81da3
2 changed files with 6 additions and 0 deletions

View File

@ -762,6 +762,8 @@ func (h *BufPane) ReplaceCmd(args []string) {
h.Cursor.SetSelectionStart(locs[0])
h.Cursor.SetSelectionEnd(locs[1])
h.Relocate()
InfoBar.YNPrompt("Perform replacement (y,n,esc)", func(yes, canceled bool) {
if !canceled && yes {
_, nrunes := h.Buf.ReplaceRegex(locs[0], locs[1], regex, replace)
@ -786,6 +788,7 @@ func (h *BufPane) ReplaceCmd(args []string) {
}
h.Buf.RelocateCursors()
h.Relocate()
var s string
if nreplaced > 1 {

View File

@ -139,6 +139,9 @@ func (w *BufWindow) Relocate() bool {
ret := false
activeC := w.Buf.GetActiveCursor()
cy := activeC.Y
if activeC.HasSelection() {
cy = activeC.CurSelection[0].Y
}
scrollmargin := int(b.Settings["scrollmargin"].(float64))
if cy < w.StartLine+scrollmargin && cy > scrollmargin-1 {
w.StartLine = cy - scrollmargin