Simplify file reload by removing cursor restoration

Removed cursor position restoration logic during file reload.
This commit is contained in:
Shamil 2025-11-15 10:22:20 +03:00 committed by GitHub
parent 884758bf85
commit d6f54a22b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -262,22 +262,8 @@ def reload(self, event):
self.text.focus_set()
return "break"
# Save cursor position
insert_pos = self.text.index("insert")
yview_pos = self.text.yview()
# Reload the file
if 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.loadfile(self.filename)
self.text.focus_set()
return "break"