Skip to content

Commit e9a3b1d

Browse files
rcoperarchl
authored andcommitted
Only read file from disk when trim_modified_lines_only is enabled
Reading file from disk is an expensive and blocking operation so do it only when option that needs it is enabled.
1 parent 61ab790 commit e9a3b1d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

trailing_spaces.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
def plugin_loaded():
3838
global ts_settings_filename, ts_settings, trailing_spaces_live_matching
3939
global current_highlighting_scope, trim_modified_lines_only, startup_queue
40-
global DEFAULT_COLOR_SCOPE_NAME, on_disk, trailing_spaces_syntax_ignore
40+
global DEFAULT_COLOR_SCOPE_NAME, trailing_spaces_syntax_ignore
4141

4242
ts_settings = sublime.load_settings(ts_settings_filename)
4343
trailing_spaces_live_matching = bool(ts_settings.get("trailing_spaces_enabled",
@@ -414,12 +414,18 @@ def on_selection_modified(self, view):
414414
match_trailing_spaces(view)
415415

416416
def on_activated(self, view):
417-
self.freeze_last_version(view)
417+
global trim_modified_lines_only
418+
if trim_modified_lines_only:
419+
self.freeze_last_version(view)
420+
418421
if trailing_spaces_live_matching:
419422
match_trailing_spaces(view)
420423

421424
def on_pre_save(self, view):
422-
self.freeze_last_version(view)
425+
global trim_modified_lines_only
426+
if trim_modified_lines_only:
427+
self.freeze_last_version(view)
428+
423429
if ts_settings.get("trailing_spaces_trim_on_save"):
424430
view.run_command("delete_trailing_spaces")
425431

0 commit comments

Comments
 (0)