Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cider-toggle-buffer-connection fails #1913

Closed
alvinfrancis opened this issue Jan 9, 2017 · 3 comments
Closed

cider-toggle-buffer-connection fails #1913

alvinfrancis opened this issue Jan 9, 2017 · 3 comments

Comments

@alvinfrancis
Copy link
Contributor

alvinfrancis commented Jan 9, 2017

Expected behavior

cider-toggle-buffer-connection should toggle between CLJ and CLJS connections (if both exist) in a clojurec-mode buffer (e.g. cljc files) or in a cider-clojure-interaction-mode buffer (e.g. *cider-scratch*). This should allow expressions to be evaluated in the appropriate connection. Also, cider-connections should still contain both CLJ and CLJS connections after toggling.

Actual behavior

Connection to REPL is seemingly lost; evaluating expressions causes CIDER to complain that a Clojure REPL is required and that a jack in is probably needed. Also, cider-connections loses one of the connections (the current one).

Steps to reproduce the problem

  1. Do lein new cider-toggle-buffer-connection
  2. Edit project.clj to the following:
(defproject cider-toggle-buffer-connection "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :url "http://example.com/FIXME"
  :license {:name "Eclipse Public License"
            :url "http://www.eclipse.org/legal/epl-v10.html"}
  :dependencies [[org.clojure/clojure "1.8.0"]
                 [com.cemerick/piggieback "0.2.1"]
                 [org.clojure/clojure "1.7.0"]]
  :repl-options {:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}
  )
  1. Do mv src/cider-toggle-buffer-connection/core.cljs src/cider-toggle-buffer-connection/core.cljc
  2. Edit src/cider-toggle-buffer-connection/core.cljc to the following:
(ns cider-toggle-buffer-connection.core)
(println "Test")
  1. Open src/cider-toggle-buffer-connection/core.cljc in emacs.
  2. Do cider-jack-in-clojurescript.
  3. Take note of the value of cider-connections: there should be two connections (CLJ and CLJS).
  4. Evaluate (println "Test") with cider-eval-last-sexp. This should print "Test" in the *cider-repl cider-toggle-buffer-connection* buffer.
  5. Do cider-toggle-buffer-connection.
  6. Evaluate (println "Test") with cider-eval-last-sexp. This should cause CIDER to complain with the following message:

user-error: ‘cider-eval-last-sexp’ needs a Clojure REPL.
If you don’t know what that means, you probably need to jack-in (‘C-c M-j’).

  1. Take note of the value of cider-connections: only the CLJS connections remains.

Environment & Version information

CIDER version information

;; CIDER 0.14.0 (Berlin), nREPL 0.2.12
;; Clojure 1.8.0, Java 1.8.0_74

Emacs version

GNU Emacs 25.1.3 (x86_64-apple-darwin15.6.0, Carbon Version 157 AppKit 1404.47) of 2016-09-18

Operating system

OSX 10.11.6

@alvinfrancis
Copy link
Contributor Author

@dpsutton

@bbatsov
Copy link
Member

bbatsov commented Jan 1, 2018

@dpsutton did you end up looking into this?

dpsutton pushed a commit to dpsutton/cider that referenced this issue Jan 2, 2018
Cljc buffers send their evals to both clj and cljs repls if available due to
`cider-map-connections`. Toggling a current buffer's connection involves hiding
the other connection.

Previously, when toggling _again_, the original list was not consulted and only
the truncated list, preventing the other connection from being found. This
allows for the full list to be searched for the other buffer.

In addition, a prefix dictates that the local connection list is discarded in
favor of the full list, restoring the evaluation in both clj and cljs
buffers (if both are present).
dpsutton pushed a commit to dpsutton/cider that referenced this issue Jan 2, 2018
Cljc buffers send their evals to both clj and cljs repls if available due to
`cider-map-connections`. Toggling a current buffer's connection involves hiding
the other connection.

Previously, when toggling _again_, the original list was not consulted and only
the truncated list, preventing the other connection from being found. This
allows for the full list to be searched for the other buffer.

In addition, a prefix dictates that the local connection list is discarded in
favor of the full list, restoring the evaluation in both clj and cljs
buffers (if both are present).
dpsutton pushed a commit to dpsutton/cider that referenced this issue Jan 2, 2018
Cljc buffers send their evals to both clj and cljs repls if available due to
`cider-map-connections`. Toggling a current buffer's connection involves hiding
the other connection.

Previously, when toggling _again_, the original list was not consulted and only
the truncated list, preventing the other connection from being found. This
allows for the full list to be searched for the other buffer.

In addition, a prefix dictates that the local connection list is discarded in
favor of the full list, restoring the evaluation in both clj and cljs
buffers (if both are present).
dpsutton pushed a commit to dpsutton/cider that referenced this issue Jan 2, 2018
Cljc buffers send their evals to both clj and cljs repls if available due to
`cider-map-connections`. Toggling a current buffer's connection involves hiding
the other connection.

Previously, when toggling _again_, the original list was not consulted and only
the truncated list, preventing the other connection from being found. This
allows for the full list to be searched for the other buffer.

In addition, a prefix dictates that the local connection list is discarded in
favor of the full list, restoring the evaluation in both clj and cljs
buffers (if both are present).
@dpsutton
Copy link
Contributor

dpsutton commented Jan 2, 2018

Something to note: the reported behavior is not correct. When eval-ing code in a cljc buffer under cider-jack-in-clojurescript, the default behavior is to eval the code in both connection buffers. So the observed behavior from (println "Test") is that both repls print "Test". After toggling, you were stuck inside of only a single connection.

This happens because the toggling worked by setting a buffer local cider-connections to hide the regular list of connections. When grabbing the cider-other-connection, it did not consult the original list but the truncated list and was therefore unable to find the other connection.

Now the behavior is

  1. eval -> "Test" in both buffers
  2. toggle
  3. eval -> "Test" in clj buffer
  4. toggle
  5. eval -> "Test" in cljs buffer
  6. toggle with prefix
  7. eval -> "Test" in both buffers

dpsutton pushed a commit to dpsutton/cider that referenced this issue Jan 3, 2018
Cljc buffers send their evals to both clj and cljs repls if available due to
`cider-map-connections`. Toggling a current buffer's connection involves hiding
the other connection.

Previously, when toggling _again_, the original list was not consulted and only
the truncated list, preventing the other connection from being found. This
allows for the full list to be searched for the other buffer.

In addition, a prefix dictates that the local connection list is discarded in
favor of the full list, restoring the evaluation in both clj and cljs
buffers (if both are present).
@bbatsov bbatsov closed this as completed in c5d4964 Jan 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants