/ oni2 Public
fix(vim/#2349): Crash on :enew #2351
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge.
:enewwould crash the editor
Defect: We were crashing when trying to infer the language type from the filename - in this code:
Line 136 in d3b6eb5
Fpathunder the hood) - is not robust against an empty filename.
Fix: Don't crash in that case - if it's an empty file name, just use the default ("plaintext") filetype. Add a regression test so we can ensure this doesn't break again in the future.
Longer term, I'd like to look at moving towards a strongly-typed solution for file path / name management - would like to integrate: https://github.com/facebookexperimental/reason-native/tree/master/src/fp