Cheryl Sabella <cheryl.sabe...@gmail.com> added the comment:
This code in editor.py controls the text that is parsed for smart indenting: if not self.context_use_ps1: for context in self.num_context_lines: startat = max(lno - context, 1) startatindex = repr(startat) + ".0" rawtext = text.get(startatindex, "insert") y.set_code(rawtext) bod = y.find_good_parse_start( self.context_use_ps1, self._build_char_in_string_func(startatindex)) if bod is not None or startat == 1: break y.set_lo(bod or 0) else: r = text.tag_prevrange("console", "insert") if r: startatindex = r[1] else: startatindex = "1.0" rawtext = text.get(startatindex, "insert") y.set_code(rawtext) y.set_lo(0) The `if not self.context_use_ps1` basically says whether the window is an editor or shell. At a high level, the editor code goes back a certain number of lines from the current cursor and the shell window goes back to just the current statement. #31858 improved the use of sys.ps1 (the prompt) and it removed setting `self.context_use_ps1` in pyshell. This meant that the `else` above was never accessed and that the shell was parsing all the text, not just the current statement. #31858 introduced `self.prompt_last_line` that is set to '' in the editor and set to the prompt in the shell. Replacing `self.context_use_ps1` with `self.prompt_last_line` allows the `else` above to be called. #32989 addresses a bug discovered with adding tests to `pyparse` where the `find_good_parse_start` call above was actually sending incorrect parameters, so removing `context_use_ps1` from that line is not an issue, but rather another bug fix. It might be preferable to merge #32989 first, therefore I'm listing that as a dependency. ---------- dependencies: +IDLE: Fix pyparse.find_good_parse_start and its bad editor call nosy: +cheryl.sabella stage: patch review -> test needed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue34055> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com