MessageInput now have a 'draft' option. When you're typing a new message, ↑...

MessageInput now have a 'draft' option. When you're typing a new message, ↑ and ↓ will keep the unfinished (and unsent) message in the history. fixed #1852
parent c2344d0d
...@@ -1024,9 +1024,12 @@ class MessageInput(Input): ...@@ -1024,9 +1024,12 @@ class MessageInput(Input):
""" """
Get the previous line in the history Get the previous line in the history
""" """
if not len(MessageInput.history):
return
self.reset_completion() self.reset_completion()
if self.histo_pos == -1 and self.get_text():
if not MessageInput.history or MessageInput.history[0] != self.get_text():
# add the message to history, we do not want to lose it
MessageInput.history.insert(0, self.get_text())
self.histo_pos += 1
if self.histo_pos < len(MessageInput.history) - 1: if self.histo_pos < len(MessageInput.history) - 1:
self.histo_pos += 1 self.histo_pos += 1
self.text = MessageInput.history[self.histo_pos] self.text = MessageInput.history[self.histo_pos]
...@@ -1036,12 +1039,16 @@ class MessageInput(Input): ...@@ -1036,12 +1039,16 @@ class MessageInput(Input):
""" """
Get the next line in the history Get the next line in the history
""" """
if not len(MessageInput.history):
return
self.reset_completion() self.reset_completion()
if self.histo_pos > 0: if self.histo_pos > 0:
self.histo_pos -= 1 self.histo_pos -= 1
self.text = MessageInput.history[self.histo_pos] self.text = MessageInput.history[self.histo_pos]
elif self.histo_pos <= 0 and self.get_text():
if not MessageInput.history or MessageInput.history[0] != self.get_text():
# add the message to history, we do not want to lose it
MessageInput.history.insert(0, self.get_text())
self.text = ''
self.histo_pos = -1
self.key_end() self.key_end()
def key_enter(self): def key_enter(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment