Skip to content

Commit

Permalink
Silently ignore deprecated newline-type (#23)
Browse files Browse the repository at this point in the history
* Catch the TypeError exception and silently discard the setting,
  which is at least better than printing a traceback every time.
  • Loading branch information
ferdnyc authored and xuhdev committed Nov 25, 2019
1 parent fa44686 commit f225350
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions editorconfig_plugin/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,18 @@ def process_properties(self, properties):

def set_end_of_line(self, document, end_of_line):
"""Set line ending style based on given end_of_line property"""
if end_of_line == "lf":
document.set_property('newline-type', 0)
elif end_of_line == "cr":
document.set_property('newline-type', 1)
elif end_of_line == "crlf":
document.set_property('newline-type', 2)
try:
if end_of_line == "lf":
document.set_property('newline-type', 0)
elif end_of_line == "cr":
document.set_property('newline-type', 1)
elif end_of_line == "crlf":
document.set_property('newline-type', 2)
except TypeError:
# 'newline-type' is deprecated in GeditDocument >= 3.14
# It was replaced with 'GtkSourceFile.newline-type', which
# we can't use because it's a read-only property.
pass

def set_indentation(self, view, indent_style, indent_size, tab_width):
"""Set indentation style for given view based on given properties"""
Expand Down

0 comments on commit f225350

Please sign in to comment.