@@ -283,13 +283,7 @@ def modified_lines_as_numbers(old, new):
283
283
#
284
284
# Returns the list of regions matching dirty lines.
285
285
def get_modified_lines (view ):
286
- try :
287
- on_disk
288
- on_buffer = view .substr (sublime .Region (0 , view .size ())).splitlines ()
289
- except UnicodeDecodeError :
290
- sublime .status_message ("File format incompatible with this feature (UTF-8 files only)" )
291
- return
292
-
286
+ on_buffer = view .substr (sublime .Region (0 , view .size ())).splitlines ()
293
287
lines = []
294
288
line_numbers = modified_lines_as_numbers (on_disk , on_buffer )
295
289
if line_numbers :
@@ -469,7 +463,19 @@ def freeze_last_version(self, view):
469
463
# For some reasons, the on_activated hook gets fired on a ghost document
470
464
# from time to time.
471
465
if file_name and not view .is_scratch () and isfile (file_name ):
472
- with codecs .open (file_name , "r" , "utf-8" ) as f :
466
+ encoding = view .encoding ()
467
+
468
+ if encoding == "Undefined" :
469
+ encoding = view .settings ().get ("default_encoding" , "UTF-8" )
470
+
471
+ if encoding == "Hexadecimal" : # not supported?
472
+ on_disk = None
473
+ return
474
+
475
+ match = re .match (r'.+\(([^)]+)\)$' , encoding )
476
+ encoding = match .group (1 ) if match else encoding
477
+
478
+ with codecs .open (file_name , "r" , encoding ) as f :
473
479
on_disk = f .read ().splitlines ()
474
480
475
481
def is_view_visible (self , view ):
0 commit comments