@@ -56,8 +56,7 @@ class FileDiffCommand(sublime_plugin.TextCommand):
5656 def diff_content (self ):
5757 content = ''
5858
59- regions = [region for region in self .view .sel ()]
60- for region in regions :
59+ for region in self .view .sel ():
6160 if region .empty ():
6261 continue
6362 content += self .view .substr (region )
@@ -131,16 +130,19 @@ def diff_with_external(self, a, b, from_file=None, to_file=None):
131130 self .view .window ().run_command ("exec" , {"cmd" : command })
132131 except Exception as e :
133132 # some basic logging here, since we are cluttering the /tmp folder
134- print repr (e )
135133 sublime .status_message (str (e ))
136134
137135 def diff_in_sublime (self , diffs ):
136+ diffs = '' .join (diffs )
138137 scratch = self .view .window ().new_file ()
139138 scratch .set_scratch (True )
140139 scratch .set_syntax_file ('Packages/Diff/Diff.tmLanguage' )
141- scratch_edit = scratch .begin_edit ('file_diffs' )
142- scratch .insert (scratch_edit , 0 , '' .join (diffs ))
143- scratch .end_edit (scratch_edit )
140+ scratch .run_command ('file_diff_dummy1' , {'content' : diffs })
141+
142+
143+ class FileDiffDummy1Command (sublime_plugin .TextCommand ):
144+ def run (self , edit , content ):
145+ self .view .insert (edit , 0 , content )
144146
145147
146148class FileDiffClipboardCommand (FileDiffCommand ):
@@ -198,8 +200,7 @@ def run(self, edit, **kwargs):
198200class FileDiffSavedCommand (FileDiffCommand ):
199201 def run (self , edit , ** kwargs ):
200202 content = ''
201- regions = [region for region in self .view .sel ()]
202- for region in regions :
203+ for region in self .view .sel ():
203204 if region .empty ():
204205 continue
205206 content += self .view .substr (region )
@@ -235,7 +236,7 @@ def on_done(index):
235236 if index > - 1 :
236237 self .run_diff (self .diff_content (), files [index ],
237238 from_file = self .view .file_name ())
238- self .view .window ().show_quick_panel (file_picker , on_done )
239+ sublime . set_timeout ( lambda : self .view .window ().show_quick_panel (file_picker , on_done ), 1 )
239240
240241 def find_files (self , folders ):
241242 # Cannot access these settings!! WHY!?
@@ -291,4 +292,4 @@ def on_done(index):
291292 on_done (0 )
292293 else :
293294 menu_items = [os .path .basename (f ) for f in files ]
294- self .view .window ().show_quick_panel (menu_items , on_done )
295+ sublime . set_timeout ( lambda : self .view .window ().show_quick_panel (menu_items , on_done ), 1 )
0 commit comments