mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Simplify file reload by removing cursor restoration
Removed cursor position restoration logic during file reload.
This commit is contained in:
parent
884758bf85
commit
d6f54a22b9
1 changed files with 1 additions and 15 deletions
|
|
@ -262,22 +262,8 @@ def reload(self, event):
|
||||||
self.text.focus_set()
|
self.text.focus_set()
|
||||||
return "break"
|
return "break"
|
||||||
|
|
||||||
# Save cursor position
|
|
||||||
insert_pos = self.text.index("insert")
|
|
||||||
yview_pos = self.text.yview()
|
|
||||||
|
|
||||||
# Reload the file
|
# Reload the file
|
||||||
if self.loadfile(self.filename):
|
self.loadfile(self.filename)
|
||||||
# Try to restore cursor position if the file still has that line
|
|
||||||
try:
|
|
||||||
self.text.mark_set("insert", insert_pos)
|
|
||||||
self.text.see("insert")
|
|
||||||
# Restore vertical scroll position
|
|
||||||
self.text.yview_moveto(yview_pos[0])
|
|
||||||
except Exception:
|
|
||||||
# If position doesn't exist anymore, go to top
|
|
||||||
self.text.mark_set("insert", "1.0")
|
|
||||||
self.text.see("insert")
|
|
||||||
|
|
||||||
self.text.focus_set()
|
self.text.focus_set()
|
||||||
return "break"
|
return "break"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue