When autodetecting whitespace settings, we should not ever come up with a tab size of 0; we should be returning None in this case, and using whatever value is present in the config system.
More generally, it would be nice to start adding test cases for this functionality. We now have a repo for testdata; it would be nice to start populating it with files that cause problems, and building up a suite of tests.
This is probably a good first issue; you would start by looking in core-lib/src/whitespace.rs, reading through that file, maybe grepping around to see where and how it is used, and then looking for the fix; it is likely some little logic error.
The file that caused this bug for me is this readme.
I implemented custom deserialization for tab_size in https://github.com/xi-editor/xi-editor/pull/1095. I think it also prevents it from crashing since now it logs the following:
[2019-01-18][22:41:53][xi_core_lib::tabs][WARN] detect_whitespace failed to update config: UnexpectedItem(Error("invalid value: integer `0`, expected tab_size must be at least 1", line: 0, column: 0))
Cool, so it looks like this issue will no longer impact the user, but we still shouldn't be returning 0 in the first place, so will leave open. :)
If I open the readme it prints file contains no indentation which should mean it already returns None, right?
Oh, there seems to be a difference when I open the file (then it says the tab_size is 0) vs. when I restart the editor and the file is already opened (returns None)
yea that's the desired outcome, but it seemed like there was some situation where it would return Some(0) instead? Not totally sure what this was, though.
Okay, I'll keep investigating 馃攷
Found the problem and pushed a fix: https://github.com/xi-editor/xi-editor/pull/1099