Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow text files to be edited even when empty #1724

Conversation

plbstl
Copy link
Contributor

@plbstl plbstl commented May 19, 2024

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

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

allow-text-files-to-be-edited-even-when-empty.mov

@thecoolwinter
Copy link
Collaborator

I'll close #1723 in favor of working on it here, it clearly doesn't solve the entire problem.

@plbstl
Copy link
Contributor Author

plbstl commented May 19, 2024

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.

@plbstl plbstl requested a review from thecoolwinter May 19, 2024 16:44
plbstl added 3 commits June 13, 2024 04:46
- CodeEditTextView 0.7.3 -> 0.7.4
- CodeEditSourceEditor 0.7.2 -> 0.7.3
- CodeEditLanguages 0.1.18 -> 0.1.19
Only check for when `CodeFileDocument.content` is not nil. If the content is an empty string, it means we're viewing an empty text file, which is a predictable behavior. Also, the extra checks cause unexpected behaviors. Check the related pull request (CodeEditApp#1724) for visuals.
@plbstl
Copy link
Contributor Author

plbstl commented Jun 13, 2024

Showing the visuals for 45c39ce

WITH EXTRA CHECKS:

specific-non-empty-files-open-with-quicklook.mov

The affected files are same as in #1722 (comment)

files without file extensions
files with only file extensions


WITHOUT THE EXTRA CHECKS:

predictable-behavior-so-far.mov

thecoolwinter
thecoolwinter previously approved these changes Jun 19, 2024
austincondiff
austincondiff previously approved these changes Jun 19, 2024
Copy link
Collaborator

@austincondiff austincondiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, please merge conflicts and we can merge

@plbstl plbstl dismissed stale reviews from austincondiff and thecoolwinter via ad75d05 June 21, 2024 08:03
@plbstl plbstl requested a review from thecoolwinter June 22, 2024 10:00
@bombardier200 bombardier200 merged commit af8c7e1 into CodeEditApp:main Jun 22, 2024
2 checks passed
@thecoolwinter thecoolwinter added the bug Something isn't working label Jul 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐞 Source editor disappears when deleting all text
5 participants