mirror of
https://github.com/sbt/sbt.git
synced 2026-08-30 17:54:25 +02:00
It was reported in https://github.com/sbt/sbt/issues/4890 that cosmetic white space could cause problems for the paser. I tracked this down to primarily being because of the `val semi = token(OptSpace ~> ';' ~> OptSpace)` line. This would cause excessive backtracking. I added a test for a multi line command with a lot of cosmetic whitespace that was adapted from #4890 except that I made it even more taxing by running adding 100 commands instead of the roughly 10 in the report. Before the parser changes, the test would more or less block indefinitely. I never saw it successfully complete. After these changes, it completes in 30-50ms (which drops to about 2-3 ms if the number of commands is dropped from 100 to 3). I verified manually in a different project that a number of different multi command completions still worked. In particular, I tested that `~foo/test; foo/tes` would expand to `~foo/test; foo/test` which is one of the hardest cases to get right. I also added a few extra test cases for the parser since I wasn't sure what the impact of removing the OptSpace ~> from the semi parser would be.