replete-repl / replete-ios

ClojureScript REPL iOS app
Eclipse Public License 1.0
395 stars 25 forks source link

Auto-square-brace makes it impossible to paste function with multiple arity #92

Open RegGuheert opened 8 years ago

RegGuheert commented 8 years ago

I've been using Replete together with "Clojure for the Brave and True" in order to learn Clojure on my iPad Air 2. All has gone well until I got to the point of trying to implement multiple-arity functions. The following example from here is where I am having some issues:

(defn x-chop
  "Describe the kind of chop you're inflicting on someone"
  ([name chop-type]
     (str "I " chop-type " chop " name "! Take that!"))
  ([name]
     (x-chop name "karate")))

When I paste this example into Replete, I get the following instead:

(defn x-chop
  "Describe the kind of chop you're inflicting on someone"
  ([name chop-type
     (str "I " chop-type " chop " name "! Take that!")])
  ([name
     (x-chop name "karate")]))

Once pasted, I find that I am completely unable to fix the position of both of the braces. I can fix one of the trailing braces, but if I fix the second one, the other one reverts to the incorrect position.

This problem does not occur if I simply type in the function definition directly. I suspect the difference has to do with how I move to the right of the square brace at the appropriate time. But the real issue seems to be the inability to fix the square brace position once it has been pasted into the entry field.

mfikes commented 8 years ago

@RegGuheert Thanks! That's interesting.

I can reproduce the problem. It appears to be caused by the lines after the binding forms being over far enough to the right, and you can work around the problem by, after pasting, placing your cursor before, say (str and tapping delete twice.

But, perhaps there is something Replete can do in this case. (Evidently Cursive handles it when in Parinfer mode).

RegGuheert commented 8 years ago

Thanks for the workaround! That will come in handy (due to the level of indentation used in the text).

paultopia commented 8 years ago

I noticed similar issues copy-pasting forms in---maybe the easiest solution is to include an option to turn off paredit/parinfer (not sure which is baked in) mode for a given input prompt?