diff --git a/internal/editor/document/document.go b/internal/editor/document/document.go index 7df1b66..94fd28d 100644 --- a/internal/editor/document/document.go +++ b/internal/editor/document/document.go @@ -67,11 +67,11 @@ func (d *Document) Save() int { } if fileLen == size { + d.dirty = false + return size } - d.dirty = false - return 0 } diff --git a/internal/editor/editor.go b/internal/editor/editor.go index f098d27..b66da9b 100644 --- a/internal/editor/editor.go +++ b/internal/editor/editor.go @@ -59,9 +59,9 @@ func (e *editor) Open(filename string) { } func (e *editor) Save() { - //if e.document.Filename == "" { - // e.document.Filename = e.Prompt("Save as: %s") - //} + if e.document.Filename == "" { + e.document.Filename = e.Prompt("Save as: %s") + } size := e.document.Save() @@ -88,24 +88,25 @@ func (e *editor) ProcessKeypress() bool { func (e *editor) Prompt(prompt string) string { buf := gilo.NewBuffer() + // Show the prompt message + e.SetStatusMessage(prompt, "") + e.RefreshScreen() + for { if buf.Len() > 0 { e.SetStatusMessage(prompt, buf.ToString()) - } else { - e.SetStatusMessage(prompt) + e.RefreshScreen() } - e.RefreshScreen() - ch, _ := terminal.ReadKey() if ch == key.Enter { if buf.Len() != 0 { e.SetStatusMessage("") return buf.ToString() - } else if !key.IsCtrl(ch) && key.IsAscii(ch) { - buf.AppendRune(ch) } + } else if key.IsAscii(ch) && !key.IsCtrl(ch) { + buf.AppendRune(ch) } } }