Fix dynamic completion clobbering *1/*2/*3 and re-requiring per request#60
Open
bbatsov wants to merge 3 commits into
Open
Fix dynamic completion clobbering *1/*2/*3 and re-requiring per request#60bbatsov wants to merge 3 commits into
bbatsov wants to merge 3 commits into
Conversation
Dynamic completion evaluates a probe in the user's REPL to introspect the object. cljs.repl's default eval wrapper rotates the history vars after every eval - (set! *3 *2) (set! *2 *1) (set! *1 ret) - so each completion request overwrote *1 with the introspection result. cljs-eval now passes a :wrap that evaluates without the history rotation (reusing cljs.repl/init-wrap-fn, which is exactly that), so completion leaves *1/*2/*3 alone.
js-properties-of-object required suitable.js-introspection on every single completion request. The default path already loads it once via ensure-suitable-cljs-is-loaded, so that require was a wasted eval round-trip per keystroke; the shadow path relied on it, so it now loads the namespace once from its ensure-loaded step (guarded by a session flag) instead. Verified against both the Node and shadow-cljs integration tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two fixes to the dynamic (JS interop) completion path.
Fixes #5 - completion clobbered
*1/*2/*3. Dynamic completion evaluates a probe in your REPL to introspect the object, and cljs.repl's default eval wrapper rotates the history vars after every eval - so each completion request overwrote*1with the introspection result.cljs-evalnow evaluates with a:wrapthat skips that rotation (reusingcljs.repl/init-wrap-fn, which is exactly this). New test that establishes*1, completes, and asserts*1survived.Fixes #6 - re-
required the introspection ns on every keystroke.js-properties-of-objectrequiredsuitable.js-introspectionon every completion request. The default path already loads it once viaensure-suitable-cljs-is-loaded, so that was a wasted eval round-trip per keystroke; the shadow path relied on it, so it now loads the ns once from itsensure-loadedstep (guarded by a session flag) instead. Verified against both the Node and shadow-cljs integration tests.Heads up: the Node integration test is a bit flaky (it occasionally fails to spawn the node process); unrelated to these changes, but a re-run clears it.