##// END OF EJS Templates
Fix disabling auto-suggestions (#13914)...
Matthias Bussonnier -
r28069:4d9852db merge
parent child Browse files
Show More
@@ -147,10 +147,6 b' class PtkHistoryAdapter(History):'
147
147
148 """
148 """
149
149
150 auto_suggest: UnionType[
151 AutoSuggestFromHistory, NavigableAutoSuggestFromHistory, None
152 ]
153
154 def __init__(self, shell):
150 def __init__(self, shell):
155 super().__init__()
151 super().__init__()
156 self.shell = shell
152 self.shell = shell
@@ -193,6 +189,9 b' class TerminalInteractiveShell(InteractiveShell):'
193 ).tag(config=True)
189 ).tag(config=True)
194
190
195 pt_app: UnionType[PromptSession, None] = None
191 pt_app: UnionType[PromptSession, None] = None
192 auto_suggest: UnionType[
193 AutoSuggestFromHistory, NavigableAutoSuggestFromHistory, None
194 ] = None
196 debugger_history = None
195 debugger_history = None
197
196
198 debugger_history_file = Unicode(
197 debugger_history_file = Unicode(
@@ -685,7 +684,6 b' class TerminalInteractiveShell(InteractiveShell):'
685
684
686 def __init__(self, *args, **kwargs) -> None:
685 def __init__(self, *args, **kwargs) -> None:
687 super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
686 super(TerminalInteractiveShell, self).__init__(*args, **kwargs)
688 self.auto_suggest = None
689 self._set_autosuggestions(self.autosuggestions_provider)
687 self._set_autosuggestions(self.autosuggestions_provider)
690 self.init_prompt_toolkit_cli()
688 self.init_prompt_toolkit_cli()
691 self.init_term_title()
689 self.init_term_title()
@@ -7,11 +7,25 b' import sys'
7 import unittest
7 import unittest
8 import os
8 import os
9
9
10 from prompt_toolkit.auto_suggest import AutoSuggestFromHistory
11
10 from IPython.core.inputtransformer import InputTransformer
12 from IPython.core.inputtransformer import InputTransformer
11 from IPython.testing import tools as tt
13 from IPython.testing import tools as tt
12 from IPython.utils.capture import capture_output
14 from IPython.utils.capture import capture_output
13
15
14 from IPython.terminal.ptutils import _elide, _adjust_completion_text_based_on_context
16 from IPython.terminal.ptutils import _elide, _adjust_completion_text_based_on_context
17 from IPython.terminal.shortcuts.auto_suggest import NavigableAutoSuggestFromHistory
18
19
20 class TestAutoSuggest(unittest.TestCase):
21 def test_changing_provider(self):
22 ip = get_ipython()
23 ip.autosuggestions_provider = None
24 self.assertEqual(ip.auto_suggest, None)
25 ip.autosuggestions_provider = "AutoSuggestFromHistory"
26 self.assertIsInstance(ip.auto_suggest, AutoSuggestFromHistory)
27 ip.autosuggestions_provider = "NavigableAutoSuggestFromHistory"
28 self.assertIsInstance(ip.auto_suggest, NavigableAutoSuggestFromHistory)
15
29
16
30
17 class TestElide(unittest.TestCase):
31 class TestElide(unittest.TestCase):
@@ -24,10 +38,10 b' class TestElide(unittest.TestCase):'
24 )
38 )
25
39
26 test_string = os.sep.join(["", 10 * "a", 10 * "b", 10 * "c", ""])
40 test_string = os.sep.join(["", 10 * "a", 10 * "b", 10 * "c", ""])
27 expect_stirng = (
41 expect_string = (
28 os.sep + "a" + "\N{HORIZONTAL ELLIPSIS}" + "b" + os.sep + 10 * "c"
42 os.sep + "a" + "\N{HORIZONTAL ELLIPSIS}" + "b" + os.sep + 10 * "c"
29 )
43 )
30 self.assertEqual(_elide(test_string, ""), expect_stirng)
44 self.assertEqual(_elide(test_string, ""), expect_string)
31
45
32 def test_elide_typed_normal(self):
46 def test_elide_typed_normal(self):
33 self.assertEqual(
47 self.assertEqual(
General Comments 0
You need to be logged in to leave comments. Login now