I’m used to edit my sources in 2 instances and every time I save changes in one instance the others in which the same source is opened offer me to reload source from the disk and delete all changes I’ve made in that instances. I wonder is there a way to make sublime ‘add’ changes from disk if the source changed (like scm git do).
Thank you!
Editing source in multiple instances
estarshono
#1
0 Likes
tito
#2
I’ve the same problem, not sure if a package exists to avoid fakes “clones”. Would be nice to have a package that automatically clones the view, when opening the same file twice. I’ll take a look
0 Likes
tito
#3
I remember now, why I did not solved this before, cloned views can’t be moved from own window. Then, if you open the same file in another window, is not possible to clone the other, and move it to replace the current one.
I got stuck here:
[code]import sublime_plugin, sublime
class Pref():
def load(self):
Pref.run = True
Pref = Pref()
Pref.load();
class Dolly(sublime_plugin.EventListener):
def on_load(self, view):
sublime.set_timeout(lambda: self.find_fake_clones(view), 1000)
sublime.set_timeout(lambda: self.find_fake_clones_run(view), 3000)
def on_post_save(self, view):
sublime.set_timeout(lambda: self.find_fake_clones(view), 1000)
sublime.set_timeout(lambda: self.find_fake_clones_run(view), 3000)
def find_fake_clones_run(self, view):
Pref.run = True
def find_fake_clones(self, view):
if Pref.run: # on save will run for each cloned view?
Pref.run = False
clones = ]
for window in sublime.windows():
for _view in window.views():
if _view.file_name() and _view.file_name() == view.file_name() and _view.buffer_id() != view.buffer_id():
# the view to clone
original_window = _view.window()
original_window.focus_view(_view)
original_window.run_command('clone_file');
good_clone = original_window.active_view();
# the view to close, and then append the clone to
fake_window = view.window()
fake_window.focus_view(view)
fake_group, fake_index = fake_window.get_view_index(view)
original_window.set_view_index(good_clone, fake_group, fake_index);
fake_window.focus_view(view)
# fake_window.run_command('close')
return
# window.run_command('close')sss
# print(clones);
# active_group() int Returns the index of the currently selected group.
# None Makes the given group active.
# focus_view(view) None Switches to the given view.
# get_view_index(view) (group, index) Returns the group, and index within the group of the view. Returns -1 if not found.
# set_view_index(view, group, index) None Moves the view to the given group and index.
[/code]
0 Likes