From 87ca18c8bef0315c8b1a66285d0b8db80ae0d4cf Mon Sep 17 00:00:00 2001 From: Eero Helenius Date: Tue, 20 Feb 2024 09:33:52 +0200 Subject: [PATCH] Use delay in highlight_evaluated_form setting --- Tutkain.sublime-settings | 6 ++++++ src/core.py | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Tutkain.sublime-settings b/Tutkain.sublime-settings index 59403ad5..32fe3dc7 100644 --- a/Tutkain.sublime-settings +++ b/Tutkain.sublime-settings @@ -137,4 +137,10 @@ // If you mainly use inline evaluation results, you might want to set this to // "false". "auto_show_output_panel": true, + + // Upon evaluating a form, temporarily highlight the form for this duration + // (in milliseconds). + // + // To disable the highlighting of forms upon evaluation, set to 0. + "highlight_evaluated_form": 3000, } diff --git a/src/core.py b/src/core.py index 2e64169e..813f1ab0 100644 --- a/src/core.py +++ b/src/core.py @@ -455,7 +455,11 @@ def noop(*args): pass def highlight_region(self, region): - if region and settings.load().get("highlight_evaluated_form", True): + if ( + region + and (delay := settings.load().get("highlight_evaluated_form", 3000)) + and delay > 0 + ): id = "tutkain/eval-" + str(uuid.uuid4()) self.view.add_regions( @@ -466,7 +470,7 @@ def highlight_region(self, region): sublime.RegionFlags.DRAW_NO_FILL, ) - sublime.set_timeout_async(lambda: self.view.erase_regions(id), 3000) + sublime.set_timeout_async(lambda: self.view.erase_regions(id), delay) def run( self,