diff --git a/internal/action/bufpane.go b/internal/action/bufpane.go index 03461fd8..f38e9734 100644 --- a/internal/action/bufpane.go +++ b/internal/action/bufpane.go @@ -275,8 +275,11 @@ func (h *BufPane) Name() string { // HandleEvent executes the tcell event properly func (h *BufPane) HandleEvent(event tcell.Event) { - if h.Buf.ExternallyModified() { - InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n)", func(yes, canceled bool) { + if h.Buf.ExternallyModified() && !h.Buf.ReloadDisabled { + InfoBar.YNPrompt("The file on disk has changed. Reload file? (y,n,esc)", func(yes, canceled bool) { + if canceled { + h.Buf.DisableReload() + } if !yes || canceled { h.Buf.UpdateModTime() } else { diff --git a/internal/buffer/buffer.go b/internal/buffer/buffer.go index c8dbb84c..c8ee1104 100644 --- a/internal/buffer/buffer.go +++ b/internal/buffer/buffer.go @@ -75,6 +75,10 @@ type SharedBuffer struct { // Type of the buffer (e.g. help, raw, scratch etc..) Type BufType + // ReloadDisabled allows the user to disable reloads if they + // are viewing a file that is constantly changing + ReloadDisabled bool + isModified bool // Whether or not suggestions can be autocompleted must be shared because // it changes based on how the buffer has changed @@ -103,6 +107,11 @@ func (b *SharedBuffer) remove(start, end Loc) []byte { return b.LineArray.remove(start, end) } +// DisableReload disables future reloads of this sharedbuffer +func (b *SharedBuffer) DisableReload() { + b.ReloadDisabled = true +} + const ( DSUnchanged = 0 DSAdded = 1