Skip to content

Commit 5eac090

Browse files
committed
Remove phantom if region is fully removed (closes #21)
1 parent 3044ae5 commit 5eac090

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Universal `Clojure REPL: Toggle Info` command acts as either `Toggle Stacktrace`
145145

146146
### Binding keys to eval code
147147

148-
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.
148+
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.
149149

150150
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:
151151

package.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,8 +396,13 @@ class SublimeClojureEvalCodeCommand(sublime_plugin.ApplicationCommand):
396396
def run(self, code):
397397
conn.erase_evals(lambda eval: isinstance(eval, StatusEval) and eval.status not in {"pending", "interrupt"})
398398
eval = StatusEval(code)
399+
ns = 'user'
400+
view = eval.active_view()
401+
if view:
402+
ns = namespace(view, view.size()) or 'user'
399403
eval.msg = {"op": "eval",
400404
"id": eval.id,
405+
"ns": ns,
401406
"code": code,
402407
"nrepl.middleware.caught/caught": f"{ns}.middleware/print-root-trace",
403408
"nrepl.middleware.print/quota": 300}
@@ -689,7 +694,7 @@ def on_activated_async(self, view):
689694
progress_thread.wake()
690695

691696
def on_modified_async(self, view):
692-
conn.erase_evals(lambda eval: eval.region() and view.substr(eval.region()) != eval.code, view)
697+
conn.erase_evals(lambda eval: not eval.region() or view.substr(eval.region()) != eval.code, view)
693698

694699
def on_close(self, view):
695700
conn.erase_evals(lambda eval: True, view)

0 commit comments

Comments
 (0)