From d8495e55899a439ca04ab07c8f236c22264be029 Mon Sep 17 00:00:00 2001 From: Marc Culler Date: Fri, 25 Oct 2024 21:56:34 -0500 Subject: [PATCH 1/2] Standardize some weird interactions in the terminal. --- python/tkterminal.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/python/tkterminal.py b/python/tkterminal.py index cd9a0c72..00fe1a00 100644 --- a/python/tkterminal.py +++ b/python/tkterminal.py @@ -351,32 +351,35 @@ def handle_keyrelease(self, event): self.text.tag_add('history', 'output_end', Tk_.INSERT) def handle_return(self, event=None): + # If the input consists of one complete line of code we run it, + # regardless of where the insert cursor is located. Otherwise we only + # run the code if the cursor is at the end of the input self.clear_completions() + if self.running_code: + return 'break' + cursor = int(self.text.index(Tk_.INSERT).split('.')[0]) + last = int(self.text.index(Tk_.END).split('.')[0]) + first = int(self.text.index('output_end').split('.')[0]) + if cursor == first == last - 1: # single line input + self.text.mark_set(Tk_.INSERT, Tk_.END) self.text.insert(Tk_.INSERT, '\n') - if not self.running_code: - cell = self.text.get('output_end', Tk_.INSERT) - self.process_return(cell) - return 'break' - - def handle_shift_return(self, event): - self.text.mark_set(Tk_.INSERT, Tk_.END) - return self.handle_return() - - def process_return(self, cell): - line, pos = map(int, self.text.index(Tk_.INSERT).split('.')) - last_line = int(self.text.index(Tk_.END).split('.')[0]) - if line == last_line - 1: - try: - self.interact_handle_input(cell) - except KeyboardInterrupt: - self.write('(IP) Keyboard Interrupt: ') - self.reset() + cell = self.text.get('output_end', Tk_.INSERT) + try: + self.interact_handle_input(cell) + except KeyboardInterrupt: + self.write('(IP) Keyboard Interrupt: ') + self.reset() self.hist_pointer = 0 self.hist_stem = '' self.interact_prompt() self.text.see(Tk_.INSERT) if self.IP.more: self.text.insert(Tk_.INSERT, ' '*self._current_indent, ()) + return 'break' + + def handle_shift_return(self, event): + self.text.mark_set(Tk_.INSERT, Tk_.END) + return self.handle_return() def jump_up(self, event): return self.handle_up(event, jump=True) From 5ed6b0f03e53f3e9fb03bed6b71e3b42a9075aba Mon Sep 17 00:00:00 2001 From: Nathan Dunfield Date: Thu, 31 Oct 2024 10:41:48 -0500 Subject: [PATCH 2/2] Sage test: don't cancel other tests if one fails --- .github/workflows/sage_test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/sage_test.yml b/.github/workflows/sage_test.yml index e2de5e02..9e391f68 100644 --- a/.github/workflows/sage_test.yml +++ b/.github/workflows/sage_test.yml @@ -9,6 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: + fail-fast: false version: [9.3, 9.4, 9.5, 9.6, 9.7, 9.8, 10.1, 10.2, 10.3, latest] container: