Sublime Forum

macOS: Refresh webpage without saving a file

#1
  • Step 1: Open macOS system settings and turn “Ask to keep changes when closing documents” off: System Settings > Desktop & Dock > Ask to keep changes when closing documents = Off.
  • Step 2: Open an HTML file in TextEdit or Xcode. Also, open this file in Safari (or another web browser).
  • Step 3: Using TextEdit or Xcode, make some changes there.
  • Step 4: Refresh the webpage in Safari. The webpage will reflect the changes you have just done.
  • Step 5: Return to TextEdit or Xcode and try to close its window. You will be prompted to save the file first.

It seems it doesn’t work for Sublime Text. What I mean is that if you have “Ask to keep changes when closing documents” on and you didn’t press Command-S in Sublime Text before updating the page in Safari, the page won’t reflect your changes.

That is, it is necessary to press Command-S first before refreshing the page? Am I correct? Is there a fix for it?

0 Likes

#2

ST has its own approach for saving, “Hot Exit” etc and IIRC doesn’t really tie in to MacOS’s standard system.

It sounds like setting "save_on_focus_lost": true in ST’s preferences will get what you want when switching focus to the browser. There are other settings in there relating to the nuances of saving and closing windows/the-app.

1 Like

#3

Hello. The problem with ‘save on focus lost’ is that it actually saves the file, which means that if you e.g. close the window with Command-W then, it will be closed without any prompt. Whereas I want keep this prompt.

0 Likes

#4

Not a Mac user here, but this request reads weird.

If a file is opened in 2 independent apps A and B at the same time, both reading content from disk, how should app B being notified about unsaved changes from app A?

Sounds like an OS-level special feature for a weird kind of content sync between two apps, which I would at best call a nieche feature request, but nothing which needs a “fix” as it is not a bug.

In a classic world app A needs to update content on disk for any other app (e.g.: B) see those changes.

As majority of modern webpages are actually dynamically handled webapps, it is required to run some sort of development server anyway to dynamically update display while working, but even this requires content to be stored to disk to trigger updates.

0 Likes

#5

I think he wants automatic checkpointing to disk (auto-saving) but with ultimately the choice presented for whether to rollback all auto-saves. There are various macOS standard features in document-based apps that are like a form of version-control.

In ST itself, I think the best you’ll get is to use Save On Focus Lost and then later hold down ⌘Z for a while. Of course if you use a version-control system like Git then you can take full control over committing and reverting.

1 Like

#6

Sublime Text saves unsaved changes in the session file periodically and keeps track of changes using both the undo-buffer and modified regions. If you don’t want ST to keep unsaved changes between restarts you can simply disable "hot_exit", then you’ll be asked to save each file on exit.

0 Likes

#7

This wouldn’t solve the expection that chrome would display unsaved content.

0 Likes

#8

Thanks you all guys. Well, okay, it seems it is not possible. It seems ST (though it is great, of course) is not integrated with macOS and its file system really well. Another sign of this is that e.g. in TextEdit, Xcode or even a free open-source CotEditor I have File > Revert to > Browse All Versions menu item, whereas in ST it is just File > Revert File, which doesn’t use Time Machine.

Or if you open a file “foo” in ST, then rename it to “foo_new” in Finder (or move it to another folder), ST won’t know that “foo_new” and “foo” are the same file, which is a native macOS feature as well.

0 Likes

#9

Sublime Text is a cross-platform editor in the first place and thus tries to implement features consistently accross all platforms to reduce friction for those switching between them.

The described time machine integration seems rather platform specific. You could however still try to open a feature request, if it is so important to you, at https://github.com/sublimehq/sublime_text/issues.

External renames not being tracked is indeed sub-optimal. A feature request/bug report for it is already pending for a while.

1 Like