Skip to content

Commit

Permalink
Merge 9e3ae95 into 3d94765
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kharbat committed Feb 20, 2017
2 parents 3d94765 + 9e3ae95 commit 363af28
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/crate/crash/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,17 @@ def __call__(self, buffer):
current_line = buffer.document.text
cursor_position = buffer.document.cursor_position


if self.last_changed and self.is_prefix(current_line.lower(), self.last_changed.lower()):
diff = len(self.last_changed) - len(current_line)
current_line = self.last_changed + current_line[diff:]

new_line = re.sub(self.KEYWORD_RE, self.keyword_replacer, current_line)
new_line = re.sub(self.KEYWORD_RE, self.keyword_replacer, current_line[:cursor_position])

if new_line != buffer.document.text:
buffer.delete_before_cursor(cursor_position)
buffer.delete(len(new_line) - cursor_position)
buffer.insert_text(new_line, fire_event=False)
buffer.insert_text(new_line, overwrite=False, move_cursor=True, fire_event=False)
self.last_changed = current_line

def keyword_replacer(self, match):
Expand Down

0 comments on commit 363af28

Please sign in to comment.