From c46695bb578db88db4ba757fb50b7a79f0dc2f3e Mon Sep 17 00:00:00 2001 From: Jawahar Suresh Babu Date: Tue, 12 Feb 2019 07:20:07 +0530 Subject: [PATCH] Fixed the issue #1049 - Endless prompt to reload changes --- cmd/micro/buffer.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cmd/micro/buffer.go b/cmd/micro/buffer.go index c0161b34..25fee91e 100644 --- a/cmd/micro/buffer.go +++ b/cmd/micro/buffer.go @@ -28,6 +28,9 @@ var ( // 1 - lf detected // 2 - crlf detected fileformat = 0 + + // If true, do not prompt to reload buffer + disableReload = false ) // Buffer stores the text for files that are loaded into the text editor @@ -347,12 +350,19 @@ func (b *Buffer) IndentString() string { // by an external program since it was last read // If it has, we ask the user if they would like to reload the file func (b *Buffer) CheckModTime() { + + if disableReload { + // User chose not to promt again + return + } + modTime, ok := GetModTime(b.Path) if ok { if modTime != b.ModTime { - choice, canceled := messenger.YesNoPrompt("The file has changed since it was last read. Reload file? (y,n)") + choice, canceled := messenger.YesNoPrompt("The file has changed since it was last read. Reload file? (y,n,esc)") messenger.Reset() messenger.Clear() + disableReload = canceled if !choice || canceled { // Don't load new changes -- do nothing b.ModTime, _ = GetModTime(b.Path)