@@ -51,8 +51,17 @@ 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+ print ('FileDiffs.sublime-settings' )
56+ settings = sublime .load_settings ('FileDiffs.sublime-settings' )
57+ os_specific_settings = {}
58+ if sublime .platform () == 'windows' :
59+ os_specific_settings = sublime .load_settings ('FileDiffs (Windows).sublime-settings' )
60+ elif sublime .platform () == 'osx' :
61+ os_specific_settings = sublime .load_settings ('FileDiffs (OSX).sublime-settings' )
62+ else :
63+ os_specific_settings = sublime .load_settings ('FileDiffs (Linux).sublime-settings' )
64+ return os_specific_settings .get (key , settings .get (key , default ))
5665
5766 def diff_content (self , view ):
5867 content = ''
@@ -72,7 +81,7 @@ def prep_content(self, ab, file_name, default_name):
7281 file_name = default_name
7382 content = [line .replace ("\r \n " , "\n " ).replace ("\r " , "\n " ) for line in content ]
7483
75- trim_trailing_white_space_before_diff = self .settings (). get ('trim_trailing_white_space_before_diff' , False )
84+ trim_trailing_white_space_before_diff = self .get_setting ('trim_trailing_white_space_before_diff' , False )
7685 if trim_trailing_white_space_before_diff :
7786 content = [line .rstrip () for line in content ]
7887
@@ -96,8 +105,8 @@ def run_diff(self, a, b, from_file, to_file, **options):
96105 else :
97106 self .view .show_popup ('<span style="font-size: 10pt">No Difference</span>' )
98107 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 )
108+ external_command = external_diff_tool or self .get_setting ('cmd' )
109+ open_in_sublime = self .get_setting ('open_in_sublime' , not external_command )
101110
102111 if external_command :
103112 self .diff_with_external (external_command , a , b , from_file , to_file , ** options )
@@ -135,7 +144,7 @@ def diff_with_external(self, external_command, a, b, from_file=None, to_file=Non
135144 with codecs .open (to_file , encoding = 'utf-8' , mode = 'w+' ) as tmp_file :
136145 tmp_file .write (b )
137146
138- trim_trailing_white_space_before_diff = self .settings (). get ('trim_trailing_white_space_before_diff' , False )
147+ trim_trailing_white_space_before_diff = self .get_setting ('trim_trailing_white_space_before_diff' , False )
139148 if trim_trailing_white_space_before_diff :
140149 def trim_trailing_white_space (file_name ):
141150 trim_lines = []
@@ -162,12 +171,13 @@ def trim_trailing_white_space(file_name):
162171 if os .path .exists (from_file ):
163172 external_command = [c .replace ('$file1' , from_file ) for c in external_command ]
164173 external_command = [c .replace ('$file2' , to_file ) for c in external_command ]
174+ external_command = [os .path .expandvars (c ) for c in external_command ]
165175 if sublime .platform () == "windows" :
166176 Popen (external_command )
167177 else :
168178 subprocess .Popen (external_command )
169179
170- apply_tempfile_changes_after_diff_tool = self .settings (). get ('apply_tempfile_changes_after_diff_tool' , False )
180+ apply_tempfile_changes_after_diff_tool = self .get_setting ('apply_tempfile_changes_after_diff_tool' , False )
171181 post_diff_tool = options .get ('post_diff_tool' )
172182 if apply_tempfile_changes_after_diff_tool and post_diff_tool is not None and (not from_file_exists or not to_file_exists ):
173183 if from_file_exists :
@@ -344,11 +354,11 @@ def on_done(index):
344354
345355 def find_files (self , folders , ret = []):
346356 # 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')
357+ # folder_exclude_patterns = self.view.get_setting ('folder_exclude_patterns')
358+ # file_exclude_patterns = self.view.get_setting ('file_exclude_patterns')
349359 folder_exclude_patterns = [".svn" , ".git" , ".hg" , "CVS" ]
350360 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 )
361+ max_files = self .get_setting ('limit' , 1000 )
352362
353363 for folder in folders :
354364 if not os .path .isdir (folder ):
@@ -406,7 +416,7 @@ def on_post_diff_tool(from_file, to_file):
406416 if len (files ) == 1 :
407417 on_done (0 )
408418 else :
409- if self .settings (). get ('expand_full_file_name_in_tab' , False ):
419+ if self .get_setting ('expand_full_file_name_in_tab' , False ):
410420 menu_items = [[os .path .basename (f ),f ] for f in files ]
411421 else :
412422 menu_items = [os .path .basename (f ) for f in files ]
0 commit comments