Kaynağa Gözat

Unselect messages after last one (#352)

cyberme0w 2 yıl önce
ebeveyn
işleme
7cf779f521
1 değiştirilmiş dosya ile 12 ekleme ve 11 silme
  1. 12 11
      cmd/messages_text.go

+ 12 - 11
cmd/messages_text.go

@@ -221,19 +221,20 @@ func (mt *MessagesText) selectNextAction() {
 		return
 	}
 
-	// If no message is currently selected, select the latest message.
-	if len(mt.GetHighlights()) == 0 {
-		mt.selectedMessage = 0
+	// If no message is currently selected, do nothing
+	if mt.selectedMessage == -1 { return }
+
+	// Otherwise select the next message. This causes the desired
+	// behaviour of unselecting messages after the last one.
+	mt.selectedMessage--
+
+	// If a message is selected, highlight it and scroll to it, otherwise remove the highlight
+	if mt.selectedMessage >= 0 {
+		mt.Highlight(ms[mt.selectedMessage].ID.String())
+	        mt.ScrollToHighlight()
 	} else {
-		if mt.selectedMessage > 0 {
-			mt.selectedMessage--
-		} else {
-			return
-		}
+		mt.Highlight()
 	}
-
-	mt.Highlight(ms[mt.selectedMessage].ID.String())
-	mt.ScrollToHighlight()
 }
 
 func (mt *MessagesText) selectFirstAction() {