File content in Sublime does not change on Git bra

2019-04-07 18:24发布

If a file is open in Sublime text 2, and then branch is switched which has changes to the file in the terminal, the file contents are not updated in the Sublime text 2 until the editor is selected by clicking on it.

How to auto-magically change it?

3条回答
可以哭但决不认输i
2楼-- · 2019-04-07 18:48

I had the same issue. Go to the git tab above and manually change the branch. that should revert the files back to any branch you want. The git tab above will work without typing anything into the terminal and will update with these git changes from sublime automatically.

查看更多
淡お忘
3楼-- · 2019-04-07 18:59

This just works in Sublime Text 2 and 3 on Mac.

查看更多
Viruses.
4楼-- · 2019-04-07 19:00

Sublime Text does not have any built-in way to do this. Though perhaps a Sublime Text plugin could do it by combining the file refresher plugin in the forum thread with a Python equivalent to watchr.

This Sublime Forum thread asks how to make a file in a different tab update automatically, given that Sublime Text is already frontmost. The asker couldn't find a way to make Sublime Text do that, but as a workaround, wrote a plugin that lets them hit a hotkey to reload all open tabs.

You could try to solve this with the same principle, by making a system-wide hotkey to switch to ST2 and back. You could implement the hotkey with AutoHotkey for Windows or Quicksilver or Keyboard Maestro for Mac. It's not as good as automatic updating, but it's the next best thing. You could hit the hotkey every time you expect the file to have changed.

You could even use a tool like watchr to monitor for changes in the files you plan to edit, and automatically triggers an AutoHotkey script or AppleScript that switches to Sublime Text and back when a file is updated. It would be even better to dispense with the GUI scripting and using Sublime Text's Python interface to reload the view without switching to it, but I don't know if Sublime Text allows you to run Python in the app from a program outside the app.

查看更多
登录 后发表回答