PR: Show whether notebook is dirty #504
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Monitor in Spyder whether a notebook has been edited after the last save. If that is the case, then put an
*(asterisk) after the filename in the title of the tab and enable the Save action. This brings the behaviour of the Notebook pane in line with the Editor pane.To implement this, we need a communication channel between the notebook JavaScript (which sends a signal if a notebook has unsaved changes) and Spyder itself. This PR uses the JavaScript
alert()function as the communication channel. If the message in the alert starts with a specific prefix (namely,:SpyderComm:), then this is interpreted as a message for Spyder and not for the user. This is perhaps a bit hacky (not using alert for what it is meant for), but it is easy to implement and I don't see a real disadvantage. The alternative would be to first open a channel to the notebook server (perhaps using Qt WebChannel) and then have the notebook server communicate with Spyder (perhaps using zeromq). I envisage that the new communication channel will have further uses.The video below shows the new behaviour implemented in this PR: after editing the notebook, an
*appears in the tab bar and the Save action is enabled; after saving, the*disappears and the Save action is disabled.dirty.mp4