Allow text files to be edited even when empty
Description
This is done by making sure the opened file can be encoded as text.
Has been tested against a plethora of file types.
Related Issues
- Fixes #1722
Checklist
- [x] I read and understood the contributing guide as well as the code of conduct
- [x] The issues this PR addresses are related to each other
- [x] My changes generate no new warnings
- [x] My code builds and runs on my machine
- [x] My changes are all related to the related issue above
- [x] I documented my code
Screenshots
https://github.com/CodeEditApp/CodeEdit/assets/49006567/1d4bc58e-b4f5-457e-9478-05854c2f870f
I'll close #1723 in favor of working on it here, it clearly doesn't solve the entire problem.
The previous commit works as expected. I made the document's content optional, we can then check to see if the content is not nil.
There is a helper sourceEditorText binding in CodeEdit/Features/Editor/Views/CodeFileView.swift for loading the text content into the CodeEditSourceEditor.
Showing the visuals for https://github.com/CodeEditApp/CodeEdit/pull/1724/commits/45c39ce9e17860fa8d8394cd320663a998e536f1
WITH EXTRA CHECKS:
https://github.com/CodeEditApp/CodeEdit/assets/49006567/e828799c-8f2e-456f-b46d-e38d6e410cef
The affected files are same as in https://github.com/CodeEditApp/CodeEdit/issues/1722#issuecomment-2119055971
files without file extensions files with only file extensions
WITHOUT THE EXTRA CHECKS:
https://github.com/CodeEditApp/CodeEdit/assets/49006567/d9897c4b-e71f-4c07-ab05-357b91a51b3b