Sublime Forum

Refresh current view

#1

Hi, is there a way to refresh current view?
When you change the view’s file (download), the file stays the same until you switch to other view and back. Is it possible to manually trigger a refresh?

Thank you

0 Likes

#2

On Windows sublime prompts me to reload the changed file when I did change it. Maybe it’s some file event issue with your OS or you disabled a setting in Sublime Text.

0 Likes

#3

Thank you for response

I am using Windows and it does prompt me, but only if the file already contained unsaved changes. Nothing is related disabled in my config. Also - as this is in plugin development section I would be glad for cross-platform solution ideally

Sublime API does not seem to feature set_dirty … maybe it’ll be possible to hack it by making that unsaved modification manually, but that’s really a hack

0 Likes

#4

I understand what you meant, now that I’m not as tired as today at 4am.
Well, since you stated that the view is only updated when you re-activate it you can also do that from within a plugin. That is, activate another view and activate the first view again. However, this would only work if you have at least 2 views in a window.

I don’t know of a way to explicitly “reload” a view from disk.

0 Likes

#5

This is actual problem for me too. Founded any solutions?

0 Likes

#6

SidebarGit does exactly that with F5. If you have installed BufferScroll, cursor position, bookmarks, folds, and can’t remember what else more will be intact.
Not best solution, but it works for me, and will be hard to beat :stuck_out_tongue:

0 Likes

#7

So there actually is a solution, I posted it here: sublimetext.com/forum/viewt … 78&p=54944

0 Likes

#8

As far as “set_dirty”, you should either save the file or revert it. You can do either of those with view.run_command.

Re: above post - If you already have a reference to the view, you can just view.run_command('revert') directly. You don’t want to accidentally revert one of the other views if they change at a bad time.

0 Likes