Skip to content

Commit efe2664

Browse files
authored
Bug fixes (#99)
* Adjust for newer API * Match \( with \) in prompttookkit mode
1 parent d628461 commit efe2664

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

mathicsscript/bindkeys.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,10 @@ def curly_right(event):
6464
def paren_left(event):
6565
b = event.cli.current_buffer
6666
b.insert_text("(")
67-
b.insert_text(")", move_cursor=False)
67+
if len(b.text) > 1 and b.text[-2] == "\\":
68+
b.insert_text("\\)", move_cursor=False)
69+
else:
70+
b.insert_text(")", move_cursor=False)
6871

6972

7073
@bindings.add(")", filter=autocomplete_on)

mathicsscript/termshell.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ def reset_lineno(self):
278278
def feed(self):
279279
prompt_str = self.get_in_prompt() if self.prompt else ""
280280
result = self.read_line(prompt_str) + "\n"
281-
if mathics_scanner.location.TRACK_LOCATIONS:
281+
if mathics_scanner.location.TRACK_LOCATIONS and self.source_text is not None:
282282
self.container.append(self.source_text)
283283
if result == "\n":
284284
return "" # end of input

mathicsscript/termshell_prompt.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from mathics.core.symbols import SymbolNull
1717
from mathics.core.systemsymbols import SymbolMessageName
1818
from mathics_pygments.lexer import MathematicaLexer, MToken
19+
from mathics_scanner.location import ContainerKind
1920
from prompt_toolkit import HTML, PromptSession, print_formatted_text
2021
from prompt_toolkit.application.current import get_app
2122
from prompt_toolkit.enums import EditingMode
@@ -67,7 +68,7 @@ def __init__(
6768
prompt: bool,
6869
edit_mode: Optional[str],
6970
):
70-
super(TerminalShellCommon, self).__init__("<stdin>")
71+
super(TerminalShellCommon, self).__init__([], ContainerKind.STREAM)
7172
self.input_encoding = locale.getpreferredencoding()
7273
self.lineno = 0
7374
self.terminal_formatter = None

0 commit comments

Comments
 (0)