Show More
@@ -1794,16 +1794,20 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||
|
1794 | 1794 | # Load the last 1000 lines from history |
|
1795 | 1795 | self.readline.clear_history() |
|
1796 | 1796 | stdin_encoding = sys.stdin.encoding or "utf-8" |
|
1797 | last_cell = u"" | |
|
1797 | 1798 | for _, _, cell in self.history_manager.get_tail(1000, |
|
1798 | 1799 | include_latest=True): |
|
1799 | if cell.strip(): # Ignore blank lines | |
|
1800 | # Ignore blank lines and consecutive duplicates | |
|
1801 | cell = cell.rstrip() | |
|
1802 | if cell and (cell != last_cell): | |
|
1800 | 1803 | if self.multiline_history: |
|
1801 |
self.readline.add_history(py3compat.unicode_to_str(cell |
|
|
1802 |
|
|
|
1804 | self.readline.add_history(py3compat.unicode_to_str(cell, | |
|
1805 | stdin_encoding)) | |
|
1803 | 1806 | else: |
|
1804 | 1807 | for line in cell.splitlines(): |
|
1805 | 1808 | self.readline.add_history(py3compat.unicode_to_str(line, |
|
1806 |
|
|
|
1809 | stdin_encoding)) | |
|
1810 | last_cell = cell | |
|
1807 | 1811 | |
|
1808 | 1812 | def set_next_input(self, s): |
|
1809 | 1813 | """ Sets the 'default' input string for the next command line. |
@@ -1815,9 +1819,7 b' class InteractiveShell(SingletonConfigurable, Magic):' | |||
|
1815 | 1819 | [D:\ipython]|1> _ip.set_next_input("Hello Word") |
|
1816 | 1820 | [D:\ipython]|2> Hello Word_ # cursor is here |
|
1817 | 1821 | """ |
|
1818 | if isinstance(s, unicode): | |
|
1819 | s = s.encode(self.stdin_encoding, 'replace') | |
|
1820 | self.rl_next_input = s | |
|
1822 | self.rl_next_input = py3compat.cast_bytes_py2(s) | |
|
1821 | 1823 | |
|
1822 | 1824 | # Maybe move this to the terminal subclass? |
|
1823 | 1825 | def pre_readline(self): |
@@ -197,7 +197,13 b' class IPythonWidget(FrontendWidget):' | |||
|
197 | 197 | # reset retry flag |
|
198 | 198 | self._retrying_history_request = False |
|
199 | 199 | history_items = content['history'] |
|
200 | items = [ line.rstrip() for _, _, line in history_items ] | |
|
200 | items = [] | |
|
201 | last_cell = u"" | |
|
202 | for _, _, cell in history_items: | |
|
203 | cell = cell.rstrip() | |
|
204 | if cell != last_cell: | |
|
205 | items.append(cell) | |
|
206 | last_cell = cell | |
|
201 | 207 | self._set_history(items) |
|
202 | 208 | |
|
203 | 209 | def _handle_pyout(self, msg): |
General Comments 0
You need to be logged in to leave comments.
Login now