Skip to content

Commit

Permalink
Remove phantom if region is fully removed (closes #21)
Browse files Browse the repository at this point in the history
  • Loading branch information
tonsky committed Nov 1, 2021
1 parent 3044ae5 commit 5eac090
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Universal `Clojure REPL: Toggle Info` command acts as either `Toggle Stacktrace`

### Binding keys to eval code

Every project is different, and sometimes it’s convenient to run a piece of code so often you’d want it on a shortcut. It might me namespace reload, test execution, database reconnect — possibilities are endless.
Every project is different, and sometimes it’s convenient to run a piece of code so often you’d want it on a shortcut. It might be a namespace reload, test execution, database reconnect, linter, formatter — possibilities are endless.

To support such use cases, Sublime Clojure allows you to bind arbitrary piece of code to a keyboard shortcut. Run `Preferences: Sublime Clojure Key Bindings` and add something like this:

Expand Down
7 changes: 6 additions & 1 deletion package.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,8 +396,13 @@ class SublimeClojureEvalCodeCommand(sublime_plugin.ApplicationCommand):
def run(self, code):
conn.erase_evals(lambda eval: isinstance(eval, StatusEval) and eval.status not in {"pending", "interrupt"})
eval = StatusEval(code)
ns = 'user'
view = eval.active_view()
if view:
ns = namespace(view, view.size()) or 'user'
eval.msg = {"op": "eval",
"id": eval.id,
"ns": ns,
"code": code,
"nrepl.middleware.caught/caught": f"{ns}.middleware/print-root-trace",
"nrepl.middleware.print/quota": 300}
Expand Down Expand Up @@ -689,7 +694,7 @@ def on_activated_async(self, view):
progress_thread.wake()

def on_modified_async(self, view):
conn.erase_evals(lambda eval: eval.region() and view.substr(eval.region()) != eval.code, view)
conn.erase_evals(lambda eval: not eval.region() or view.substr(eval.region()) != eval.code, view)

def on_close(self, view):
conn.erase_evals(lambda eval: True, view)
Expand Down

0 comments on commit 5eac090

Please sign in to comment.