Provide encoding information to user when guessing encoding other than UTF-8
If we've guessed an encoding for a document and that is not UTF-8, we need to display that to the user so that we can ensure that they may save the document back in an encoding that is useful.
Additionally, they may need to re-open the document using that same preferred encoding.
I believe we already store encoding information in either the session or extended attributes, so that should also be checked to ensure that we re-open the document with the proper encoding on subsequent requests without notifying the user and without falling back to another encoding.
This is much harder to auto-mate tests for, but it'd be nice to test too.
Implementation Notes
For anyone wanting to work on this, the first spot is probably to look at EditorDocument
and find where we use a GtkSourceFileLoader
to load the document. We call gtk_source_file_loader_set_candidate_encodings()
when we do know the encoding.
In the typical flow were the user has not selected an encoding, we will never call gtk_source_file_loader_set_candidate_encodings()
. As part of the loading, the GtkSourceView
infrastructure should end up setting the GtkSourceFile:encoding
property for the GtkSourceFile
used. That could be checked for something other than UTF-8 along with the candidate_encodings being NULL
to very likely detect this situation.
In addition to that, we'll need a new infobar w/ the options for the user to select (a drop down for candidate encodings, etc) with the ability to reload the document in that encoding.