]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/messenger.go
Fix replace cursor relocation
[micro.git] / cmd / micro / messenger.go
index 50100c4040598e4cced7ffdfc5e06e2cf79685f3..1542c1c8a6000a3d47c694fb91a439e65e75168f 100644 (file)
@@ -106,7 +106,7 @@ func (m *Messenger) YesNoPrompt(prompt string) (bool, bool) {
                m.Display()
                screen.ShowCursor(Count(m.message), h-1)
                screen.Show()
-               event := screen.PollEvent()
+               event := <-events
 
                switch e := event.(type) {
                case *tcell.EventKey:
@@ -149,7 +149,7 @@ func (m *Messenger) Prompt(prompt, historyType string, completionType Completion
                m.Clear()
                m.Display()
 
-               event := screen.PollEvent()
+               event := <-events
 
                switch e := event.(type) {
                case *tcell.EventKey:
@@ -186,7 +186,11 @@ func (m *Messenger) Prompt(prompt, historyType string, completionType Completion
                                                }
                                        }
                                        if len(suggestions) == 1 {
-                                               m.response = strings.Join(dirs[:len(dirs)-1], "/") + "/" + suggestions[0]
+                                               if len(dirs) > 1 {
+                                                       m.response = strings.Join(dirs[:len(dirs)-1], "/") + "/" + suggestions[0]
+                                               } else {
+                                                       m.response = suggestions[0]
+                                               }
                                                m.cursorx = Count(m.response)
                                        }
                                }