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

Implement option to show files with unknown characters as new document #1283

Merged
merged 10 commits into from
Mar 24, 2023

Conversation

jeremypw
Copy link
Collaborator

Fixes #1282

It turns out we are loading corrupt or non-text files into a buffer anyway and I presume Gtk.SourceFileLoader can be trusted to produce a valid (if not very readable) text file. This PR adds an option to the AlertView to show what was loaded when a non-empty string was produced. Because we do not want the original file to be inadvertently overwritten, the loaded text is used to create a new document.

When no text is loaded we can assume it was because the content of the file was not accessible due to permissions or other problem (an empty readable file is always valid). The text and presence of the option is therefore modified depending on whether any text was loaded.

@jeremypw jeremypw marked this pull request as ready for review March 16, 2023 10:57
@jeremypw jeremypw requested a review from a team March 16, 2023 10:58
zeebok
zeebok previously approved these changes Mar 17, 2023
@jeremypw
Copy link
Collaborator Author

On initial opening of corrupted file:
Screenshot from 2023-03-17 17 41 40

After loading as text:
Screenshot from 2023-03-17 17 49 51

Attempt to load file with no read permission:
Screenshot from 2023-03-17 17 47 19

@jeremypw
Copy link
Collaborator Author

@danirabbit You may wish to comment on the text or other design matters.

Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

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

Just a couple small comments!

src/Services/Document.vala Outdated Show resolved Hide resolved
src/Services/Document.vala Outdated Show resolved Hide resolved
Copy link
Member

@danirabbit danirabbit left a comment

Choose a reason for hiding this comment

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

Works as expected. Nice fix!

@danirabbit danirabbit merged commit 5eba475 into master Mar 24, 2023
@danirabbit danirabbit deleted the show-corrupt-anyway branch March 24, 2023 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot open files with unknown characters
4 participants