[meld/meld-3-18] filediff: Remove non-functional encoding fallback check (#239)
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld/meld-3-18] filediff: Remove non-functional encoding fallback check (#239)
- Date: Tue, 13 Nov 2018 20:08:11 +0000 (UTC)
commit c7bbe78d12e05f17c7660dbfd8913607546daed7
Author: Kai Willadsen <kai willadsen gmail com>
Date: Wed Nov 14 06:01:41 2018 +1000
filediff: Remove non-functional encoding fallback check (#239)
The intention of this check is to allow users to fall back to using
UTF-8 if, for example, they loaded a file that was auto-detected as
ASCII and then typed in anything outside of that charset.
Clearly this is a niche use case because it hasn't worked since 3.15.2
(because we never use the assigned-to `source_encoding`), and no one has
complained about the fallback; the bug here is that the check itself
doesn't work any more.
In 3.19.x this is fixable by the user with the new encoding selector, so
realistically that's probably going to be the answer here.
meld/filediff.py | 32 --------------------------------
1 file changed, 32 deletions(-)
---
diff --git a/meld/filediff.py b/meld/filediff.py
index 08a28c6f..d6ef1ade 100644
--- a/meld/filediff.py
+++ b/meld/filediff.py
@@ -1481,38 +1481,6 @@ class FileDiff(melddoc.MeldDoc, gnomeglade.Component):
msgarea.show_all()
return False
- start, end = buf.get_bounds()
- text = buf.get_text(start, end, False)
-
- source_encoding = bufdata.sourcefile.get_encoding()
- if not source_encoding:
- # no encoding for new blank comparison
- source_encoding = GtkSource.Encoding.get_utf8()
-
- while isinstance(text, str):
- try:
- encoding = source_encoding.get_charset()
- text = text.encode(encoding)
- except UnicodeEncodeError:
- dialog_buttons = [
- (_("_Cancel"), Gtk.ResponseType.CANCEL),
- (_("_Save as UTF-8"), Gtk.ResponseType.OK),
- ]
- reencode = misc.modal_dialog(
- primary=_(u"Couldn't encode text as “%s”") % encoding,
- secondary=_(
- u"File “%s” contains characters that can't be encoded "
- u"using encoding “%s”.\n"
- u"Would you like to save as UTF-8?") % (
- bufdata.label, encoding),
- buttons=dialog_buttons,
- messagetype=Gtk.MessageType.WARNING
- )
- if reencode != Gtk.ResponseType.OK:
- return False
-
- source_encoding = GtkSource.Encoding.get_utf8()
-
saver = GtkSource.FileSaver.new_with_target(
self.textbuffer[pane], bufdata.sourcefile, bufdata.gfiletarget)
# TODO: Think about removing this flag and above handling, and instead
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]