Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prefer any valid solution over an invalid one, regardless of overflow.
While the Solver is working through Solutions, it keeps track of the best Solution it's found so far. This will get returned if there is no Solution that fits within the page width: when overflow is inevitable, the formatter still tries to do the best it can. The Solver is careful to not consider an invalid solution (one that contains a newline where none is allowed) to be the best solution. Except in one case: If the *initial* solution is invalid, the Solver will still store it in best. Then, as long as no other solution has less overflow than the initial invalid one, it ends up returning an invalid solution. This fixes that: any valid solution, regardless of overflow, will kick out that initial invalid solution if there is one.
- Loading branch information