FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[3.13] gh-94523: IDLE: Detect file if modified and prompt the user to refresh (GH-145625) by miss-islington · Pull Request #152988 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
20 changes: 20 additions & 0 deletions Lib/idlelib/editor.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,9 @@ def __init__(self, flist=None, filename=None, key=None, root=None):
else:
self.update_menu_state('options', '*ine*umbers', 'disabled')

self.mtime = self.last_mtime()
text_frame.bind('<FocusIn>', self.focus_in_event)

def handle_winconfig(self, event=None):
self.set_width()

Expand Down Expand Up @@ -1027,6 +1030,8 @@ def get_saved(self):

def set_saved(self, flag):
self.undo.set_saved(flag)
if flag:
self.mtime = self.last_mtime()

def reset_undo(self):
self.undo.reset_undo()
Expand Down Expand Up @@ -1112,6 +1117,21 @@ def _close(self):
# unless override: unregister from flist, terminate if last window
self.close_hook()

def last_mtime(self):
file = self.io.filename
return os.path.getmtime(file) if file else 0

def focus_in_event(self, event):
mtime = self.last_mtime()
if self.mtime != mtime:
self.mtime = mtime
if self. askyesno(
'Reload', '"%s"\n\nThis script has been modified by another program.'
'\nDo you want to reload it?' % self.io.filename, parent=self.text):
self.io.loadfile(self.io.filename)
else:
self.set_saved(False)

def load_extensions(self):
self.extensions = {}
self.load_standard_extensions()
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Detect file if modified at local disk and prompt to ask refresh. Patch by
Shixian Li.
Loading

Back | FazBrowse Home | New Git URL