Skip to content

Commit

Permalink
Use delay in highlight_evaluated_form setting
Browse files Browse the repository at this point in the history
  • Loading branch information
eerohele committed Feb 20, 2024
1 parent 48c67f5 commit 87ca18c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions Tutkain.sublime-settings
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
8 changes: 6 additions & 2 deletions src/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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,
Expand Down

0 comments on commit 87ca18c

Please sign in to comment.