@@ -51,8 +51,16 @@ def on_done(index):
5151
5252
5353class FileDiffCommand (sublime_plugin .TextCommand ):
54- def settings (self ):
55- return sublime .load_settings ('FileDiffs.sublime-settings' )
54+ def get_setting (self , key , default = None ):
55+ settings = sublime .load_settings ('FileDiffs.sublime-settings' )
56+ os_specific_settings = {}
57+ if sublime .platform () == 'windows' :
58+ os_specific_settings = sublime .load_settings ('FileDiffs (Windows).sublime-settings' )
59+ elif sublime .platform () == 'osx' :
60+ os_specific_settings = sublime .load_settings ('FileDiffs (OSX).sublime-settings' )
61+ else :
62+ os_specific_settings = sublime .load_settings ('FileDiffs (Linux).sublime-settings' )
63+ return os_specific_settings .get (key , settings .get (key , default ))
5664
5765 def diff_content (self , view ):
5866 content = ''
@@ -72,7 +80,7 @@ def prep_content(self, ab, file_name, default_name):
7280 file_name = default_name
7381 content = [line .replace ("\r \n " , "\n " ).replace ("\r " , "\n " ) for line in content ]
7482
75- trim_trailing_white_space_before_diff = self .settings (). get ('trim_trailing_white_space_before_diff' , False )
83+ trim_trailing_white_space_before_diff = self .get_setting ('trim_trailing_white_space_before_diff' , False )
7684 if trim_trailing_white_space_before_diff :
7785 content = [line .rstrip () for line in content ]
7886
@@ -96,8 +104,8 @@ def run_diff(self, a, b, from_file, to_file, **options):
96104 else :
97105 self .view .show_popup ('<span style="font-size: 10pt">No Difference</span>' )
98106 else :
99- external_command = external_diff_tool or self .settings (). get ('cmd' )
100- open_in_sublime = self .settings (). get ('open_in_sublime' , not external_command )
107+ external_command = external_diff_tool or self .get_setting ('cmd' )
108+ open_in_sublime = self .get_setting ('open_in_sublime' , not external_command )
101109
102110 if external_command :
103111 self .diff_with_external (external_command , a , b , from_file , to_file , ** options )
@@ -135,7 +143,7 @@ def diff_with_external(self, external_command, a, b, from_file=None, to_file=Non
135143 with codecs .open (to_file , encoding = 'utf-8' , mode = 'w+' ) as tmp_file :
136144 tmp_file .write (b )
137145
138- trim_trailing_white_space_before_diff = self .settings (). get ('trim_trailing_white_space_before_diff' , False )
146+ trim_trailing_white_space_before_diff = self .get_setting ('trim_trailing_white_space_before_diff' , False )
139147 if trim_trailing_white_space_before_diff :
140148 def trim_trailing_white_space (file_name ):
141149 trim_lines = []
@@ -162,12 +170,13 @@ def trim_trailing_white_space(file_name):
162170 if os .path .exists (from_file ):
163171 external_command = [c .replace ('$file1' , from_file ) for c in external_command ]
164172 external_command = [c .replace ('$file2' , to_file ) for c in external_command ]
173+ external_command = [os .path .expandvars (c ) for c in external_command ]
165174 if sublime .platform () == "windows" :
166175 Popen (external_command )
167176 else :
168177 subprocess .Popen (external_command )
169178
170- apply_tempfile_changes_after_diff_tool = self .settings (). get ('apply_tempfile_changes_after_diff_tool' , False )
179+ apply_tempfile_changes_after_diff_tool = self .get_setting ('apply_tempfile_changes_after_diff_tool' , False )
171180 post_diff_tool = options .get ('post_diff_tool' )
172181 if apply_tempfile_changes_after_diff_tool and post_diff_tool is not None and (not from_file_exists or not to_file_exists ):
173182 if from_file_exists :
@@ -344,11 +353,11 @@ def on_done(index):
344353
345354 def find_files (self , folders , ret = []):
346355 # Cannot access these settings!! WHY!?
347- # folder_exclude_patterns = self.view.settings().get ('folder_exclude_patterns')
348- # file_exclude_patterns = self.view.settings().get ('file_exclude_patterns')
356+ # folder_exclude_patterns = self.view.get_setting ('folder_exclude_patterns')
357+ # file_exclude_patterns = self.view.get_setting ('file_exclude_patterns')
349358 folder_exclude_patterns = [".svn" , ".git" , ".hg" , "CVS" ]
350359 file_exclude_patterns = ["*.pyc" , "*.pyo" , "*.exe" , "*.dll" , "*.obj" , "*.o" , "*.a" , "*.lib" , "*.so" , "*.dylib" , "*.ncb" , "*.sdf" , "*.suo" , "*.pdb" , "*.idb" , ".DS_Store" , "*.class" , "*.psd" , "*.db" ]
351- max_files = self .settings (). get ('limit' , 1000 )
360+ max_files = self .get_setting ('limit' , 1000 )
352361
353362 for folder in folders :
354363 if not os .path .isdir (folder ):
@@ -406,7 +415,7 @@ def on_post_diff_tool(from_file, to_file):
406415 if len (files ) == 1 :
407416 on_done (0 )
408417 else :
409- if self .settings (). get ('expand_full_file_name_in_tab' , False ):
418+ if self .get_setting ('expand_full_file_name_in_tab' , False ):
410419 menu_items = [[os .path .basename (f ),f ] for f in files ]
411420 else :
412421 menu_items = [os .path .basename (f ) for f in files ]
0 commit comments