Cheryl Sabella <chek...@gmail.com> added the comment: > In the meanwhile, to get some idea of how well find_good_parse_start finds > good parse starts, I restarted IDLE in a console with the print still added, > loaded editor.py, and hit RETURN followed by UNDO, in various places. The > first non-zero bod, 812, comes with the cursor at the end of 'def > _sphinx_version():' 812 is probably the beginning of the line. After "if > __name__ == '__main__':" near the end, 1416. After the final > "run(_editor_window)", 1654. The highest value I got in about 10 tries past > the middle, 1931. To me, this is pathetically bad.
Print `startat` too. `num_context_lines` isn't CodeContext (although I thought it was too); that's just unfortunate naming. `num_context_lines` is just a list = [50, 500, 5000]. First it looks at the code going back 50 lines from the current line and it only sends the text to `find_good_parse_start()` from this line onward. `bod` is calculated from that point, not from the beginning of the file. Because the start point is always 50 lines back, `bod` seems to always be in a similar range once you get to line 50 or higher in the code. It seems that the purpose of the parsing is to apply the translate, etc to as few lines as possible. So, it tries to make sure it includes the openers (':' ending lines) and closers (return, pass, etc) and the beginning of the brackets and continuation lines. The big thing is that it wants to make sure it's not in a string or comment. So, I think the program almost overcompensates for the idea of a 'large string'. It is very complex and very hard to figure out exactly what it is trying to accomplish, even with the comments. Maybe modern computing power (compared to 2000) has made it such that translating a whole source file is quick enough to not need fancy parsing. :-) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue32989> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com