bpo-35610: IDLE - Replace .context_use_ps1 with .prompt_last_line (GH-11307)

Changes in bpo- 31858 made the less informative 'context_use_ps1' redundant.
This commit is contained in:
Cheryl Sabella 2019-06-02 14:56:47 -04:00 committed by Terry Jan Reedy
parent 5df4025f42
commit 6bdc4dee01
8 changed files with 13 additions and 13 deletions

View File

@ -3,6 +3,9 @@ Released on 2019-10-20?
====================================== ======================================
bpo-35610: Replace now redundant editor.context_use_ps1 with
.prompt_last_line. This finishes change started in bpo-31858.
bpo-32411: Stop sorting dict created with desired line order. bpo-32411: Stop sorting dict created with desired line order.
bpo-37038: Make idlelib.run runnable; add test clause. bpo-37038: Make idlelib.run runnable; add test clause.

View File

@ -228,10 +228,6 @@ class EditorWindow(object):
self.indentwidth = self.tabwidth self.indentwidth = self.tabwidth
self.set_notabs_indentwidth() self.set_notabs_indentwidth()
# If context_use_ps1 is true, parsing searches back for a ps1 line;
# else searches for a popular (if, def, ...) Python stmt.
self.context_use_ps1 = False
# When searching backwards for a reliable place to begin parsing, # When searching backwards for a reliable place to begin parsing,
# first start num_context_lines[0] lines back, then # first start num_context_lines[0] lines back, then
# num_context_lines[1] lines back if that didn't work, and so on. # num_context_lines[1] lines back if that didn't work, and so on.
@ -1337,14 +1333,13 @@ class EditorWindow(object):
# open/close first need to find the last stmt # open/close first need to find the last stmt
lno = index2line(text.index('insert')) lno = index2line(text.index('insert'))
y = pyparse.Parser(self.indentwidth, self.tabwidth) y = pyparse.Parser(self.indentwidth, self.tabwidth)
if not self.context_use_ps1: if not self.prompt_last_line:
for context in self.num_context_lines: for context in self.num_context_lines:
startat = max(lno - context, 1) startat = max(lno - context, 1)
startatindex = repr(startat) + ".0" startatindex = repr(startat) + ".0"
rawtext = text.get(startatindex, "insert") rawtext = text.get(startatindex, "insert")
y.set_code(rawtext) y.set_code(rawtext)
bod = y.find_good_parse_start( bod = y.find_good_parse_start(
self.context_use_ps1,
self._build_char_in_string_func(startatindex)) self._build_char_in_string_func(startatindex))
if bod is not None or startat == 1: if bod is not None or startat == 1:
break break

View File

@ -35,7 +35,7 @@ class HyperParser:
return int(float(index)) return int(float(index))
lno = index2line(text.index(index)) lno = index2line(text.index(index))
if not editwin.context_use_ps1: if not editwin.prompt_last_line:
for context in editwin.num_context_lines: for context in editwin.num_context_lines:
startat = max(lno - context, 1) startat = max(lno - context, 1)
startatindex = repr(startat) + ".0" startatindex = repr(startat) + ".0"

View File

@ -19,7 +19,7 @@ class DummyEditwin:
self.text = text self.text = text
self.indentwidth = 8 self.indentwidth = 8
self.tabwidth = 8 self.tabwidth = 8
self.context_use_ps1 = True self.prompt_last_line = '>>>' # Currently not used by autocomplete.
class AutoCompleteTest(unittest.TestCase): class AutoCompleteTest(unittest.TestCase):

View File

@ -11,7 +11,7 @@ class DummyEditwin:
self.text = text self.text = text
self.indentwidth = 8 self.indentwidth = 8
self.tabwidth = 8 self.tabwidth = 8
self.context_use_ps1 = True self.prompt_last_line = '>>>'
self.num_context_lines = 50, 500, 1000 self.num_context_lines = 50, 500, 1000
_build_char_in_string_func = EditorWindow._build_char_in_string_func _build_char_in_string_func = EditorWindow._build_char_in_string_func
@ -53,7 +53,7 @@ class HyperParserTest(unittest.TestCase):
def tearDown(self): def tearDown(self):
self.text.delete('1.0', 'end') self.text.delete('1.0', 'end')
self.editwin.context_use_ps1 = True self.editwin.prompt_last_line = '>>>'
def get_parser(self, index): def get_parser(self, index):
""" """
@ -71,7 +71,7 @@ class HyperParserTest(unittest.TestCase):
self.assertIn('precedes', str(ve.exception)) self.assertIn('precedes', str(ve.exception))
# test without ps1 # test without ps1
self.editwin.context_use_ps1 = False self.editwin.prompt_last_line = ''
# number of lines lesser than 50 # number of lines lesser than 50
p = self.get_parser('end') p = self.get_parser('end')

View File

@ -17,7 +17,7 @@ class DummyEditwin:
self.text = text self.text = text
self.indentwidth = 8 self.indentwidth = 8
self.tabwidth = 8 self.tabwidth = 8
self.context_use_ps1 = True self.prompt_last_line = '>>>' # Currently not used by parenmatch.
class ParenMatchTest(unittest.TestCase): class ParenMatchTest(unittest.TestCase):

View File

@ -881,7 +881,7 @@ class PyShell(OutputWindow):
self.usetabs = True self.usetabs = True
# indentwidth must be 8 when using tabs. See note in EditorWindow: # indentwidth must be 8 when using tabs. See note in EditorWindow:
self.indentwidth = 8 self.indentwidth = 8
self.context_use_ps1 = True
self.sys_ps1 = sys.ps1 if hasattr(sys, 'ps1') else '>>> ' self.sys_ps1 = sys.ps1 if hasattr(sys, 'ps1') else '>>> '
self.prompt_last_line = self.sys_ps1.split('\n')[-1] self.prompt_last_line = self.sys_ps1.split('\n')[-1]
self.prompt = self.sys_ps1 # Changes when debug active self.prompt = self.sys_ps1 # Changes when debug active

View File

@ -0,0 +1,2 @@
Replace now redundant .context_use_ps1 with .prompt_last_line. This finishes
change started in bpo-31858.