@cfleming: good point! I think I can just adjust result.indentDelta
at commitChar
since we can detect when characters are added/deleted there
@cfleming: had a chance to look at it, this kind of thing can only happen when forceBalance
is true, and i did a quick sandbox test, and it seems to work well with the fix i described
pushed 3.0.1 with the fix
unfortunately none of the indentMode tests are running with forceBalance
, but I made an issue to fix that and will be able to verify more fully then
@sekao: yeah, rubber-ducking is definitely what it is! I didn’t open reddit/twitter/hackernews at all, which is a miracle
Ok. I found a case yesterday which didn’t work correctly, at least in Atom - I haven’t had time to make a test case yet.
(if (or true
false)
(do-something))
If I use lisp-paredit
to wrap the (or...)
in parens, I get:
(if ((or true
false))
(do-something))
The false
is indented one space too many.
@shaunlebron ^^
ah, yeah, I should note that forceBalance
is defaulted to true in my fork because @chrisoakman doesn't like the v2 changes (and my fork was originally an actual PR)
@cfleming: hmm, can’t reproduce in sandbox.js. you can try this there:
console.log(parinfer.testIndentMode(`
(if ((or true
+
false))
+
(do-something))
`));
I get the following output:
(if ((or true
false))
(do-something))
@shaunlebron Ok, I’ll check it out later. It might also be a problem with the Atom integration - @rgdelato might have an idea why.
Possibly the changes are not in sorted order, or something like that?
actually, the changes can be given in any order I just realized, since I’m just creating a map from it
Are there any notes on making better tabstops from the parinfer output?
For example, when the char is (
, the next nice indent is either +2 or +1+first-word-length
Oh, is the open char always (x-1) on lineNo?
the tabstops are the positions of the parent open-parens
your example is the intended usage—determining your own offset from the open paren
lemme get an example
@eraserhd the test cases for tabstops shows examples of where the tabstops are: https://github.com/shaunlebron/parinfer/blob/master/lib/test/cases/indent-mode.md#tab-stops
lemme know if that answers your question
yup
I love your tests, by the way. I do that sort of thing a bunch, and people usually whine about how much effort it is until they see it.
would love to see your take on these kinds of tests if public!
Hmm, some are.
Well, kind of. Here's from avi, a vim clone that I sort of don't work on anymore: https://github.com/maitria/avi/blob/master/test/avi/t_splits.clj#L67-L75
I was trying to rewrite them to do this: https://github.com/maitria/avi/blob/master/test/spec.txt
My best was when working on iPad games. For Polar Puzzles, there were ascii characters for all the board pieces, and each case was run in all four rotations. https://itunes.apple.com/us/app/polar-puzzles-free/id450788000?mt=8