editorconfig / editorconfig-gedit

EditorConfig plugin for Gedit
http://editorconfig.org
Other
54 stars 13 forks source link

Patch around GEdit 3.36 API breakage #25

Closed ferdnyc closed 3 years ago

ferdnyc commented 4 years ago

Seems GEdit 3.36 changes the document location API for no discernible reason. Now,

# instead of
document.get_location().get_uri()
# it's
document.get_file().get_location().get_uri()

(Waiting for .get_scheme().get_path().get_string().get_first_character()... :roll_eyes: )

Eliminates constant annoying message like this in the terminal:

Traceback (most recent call last):
  File "/usr/lib64/gedit/plugins/editorconfig_plugin/shared.py", line 34, in set_config
    props = self.get_document_properties(document)
  File "/usr/lib64/gedit/plugins/editorconfig_plugin/gedit3.py", line 44, in get_document_properties
    location = document.get_location()
AttributeError: 'Document' object has no attribute 'get_location'

Many thanks to developer @maoschanz who already sorted this out in maoschanz/gedit-plugin-markdown_preview#23, and made it real easy to crib from their code after a web search.

maoschanz commented 4 years ago

if you read the python help like me (the logic thing to do when developing in python) the problem is unexpected, but i discovered there is actually also a C doc where this method is labelled as deprecated since 2014 https://developer.gnome.org/gedit/3.30/GeditDocument.html#gedit-document-get-location so the reason they broke it is probably that they assume we had enough time to use the replacement

aside of the poor python help, the actual issue is that they didn't release that C doc since 3.30, so the version 3.36 where they removed these deprecated methods is kinda undocumented

anieuwland commented 3 years ago

Who needs to look at this PR to get it merged?

ferdnyc commented 3 years ago

It looks like @xuhdev has merged every commit that's gone into the repo for the past few years, except a few that @treyhunner committed directly?

xuhdev commented 3 years ago

Sorry for the delay. I don't have gedit 3.36 (I only have 3.30). I can verify this change doesn't break 3.30, but it would be difficult for me to verify 3.36. Do you have exactly the reference that it is supposed to break in 3.36? Is it also a bug on gedit's side?

And thanks for the contribution! I apologize for the delay.

ferdnyc commented 3 years ago

@xuhdev Yeah, I don't know that there's really any reference for the removal — the link that @maoschanz provided is probably the closest we'll get, as it shows that by 3.30 gedit_document_get_location() had been deprecated since 3.14.

They haven't published any newer versions of the API doc, so we can't see that it's explicitly removed from 3.36, but that seems the obvious conclusion. (Nor would I be surprised if removing an API that'd been marked deprecated for the past 11 releases was done with little fanfare.)

anieuwland commented 3 years ago

Sorry for not responding earlier. I can confirm editorconfig-gedit now works again on gedit 3.38, while it didn't before this was merged. Thanks @xuhdev.