Closed shaunlebron closed 7 years ago
some progress on test cases. not liking the implementation so far (still broken): https://github.com/shaunlebron/parinfer/commit/52e5d5840b83bcc2908adcd0a9dd558e463d58c7
@oakmac which option do you expect below?
(foo (bar |) baz ... )
; ^ insert a "(" here
;; option A
(foo (bar (|) baz ... ))
;; option B
(foo (bar (|)) baz ... )
Some unpredictability emerging. Even with our conservative constraints, this craziness happens:
(let [{:keys [|foo bar]} my-map])
; ^ backspace
(let [{:keys |foo bar}] my-map)
; ^^ swapped
step by step:
(let [{:keys [|foo bar]} my-map])
; ^ backspace
(let [{:keys |foo bar]} my-map])
; ^ unbalanced on right side of cursor
(let [{:keys |foo bar}]} my-map])
; ^ infer closing curly
(let [{:keys |foo bar}]} my-map])
; ^ ^ remove unmatched
(let [{:keys |foo bar}] my-map)
context from v2 decision is returning to me, so now that i've double-checked this rabbit hole:
(a
(b
(c
d)
e)^
f)^
^
(a (b (c d) e) f)
^ ^
unmatched paren is removed, with the following results:
unmatched paren is highlighted RED, with the following results:
v3 will have an option onBadInnerParen: 'erase' | 'suspend'
. Default is suspend.
published 2.1.0 without the option, and with a few other fixes.
@oakmac if you or anyone wants to revisit Oakinfer, I outlined all the test cases that will have to be accounted for here: https://github.com/shaunlebron/parinfer/blob/master/lib/test/cases/indent-mode.md#unmatched-close-parens
Due to the negative reaction to Parinfer v2 allowing unbalanced code as a means to prevent the breaking behavior in Parinfer v1, an alternative to both is being explored under the name Oakinfer. Original discussion: https://github.com/oakmac/atom-parinfer/issues/76
Expected Cases
The challenge is to find rules to implement the conflicting expected cases:
Rule Proposals
One way to do this is to use the cursor position to distinguish the two cases:
(
or even pasting(foo
will both perform a wrap as far as it can)
will "slurp" the expression without affecting othersConstraining for Sanity
Only infer a paren to the right of the cursor if the most recent paren is an open-paren. This will still allow the following "barf" case:
Will explore other cases that will require further constraints.