Skip to content
Browse files

use default if encoding of view is undefined

  • Loading branch information...
1 parent 457f6ef commit a350b4ae541f05b9ee20f2a7525496a67c417dbe @jedy jedy committed Aug 2, 2012
Showing with 5 additions and 2 deletions.
  1. +5 −2 Tidy.py
View
7 Tidy.py
@@ -32,8 +32,11 @@ def run(self, edit):
setup()
view = self.view
region = Region(0L, view.size())
- source = StringIO(view.substr(region).encode(view.encoding()))
+ encoding = view.encoding()
+ if not encoding or encoding == u'Undefined':
+ encoding = view.settings().get('default_encoding')
+ source = StringIO(view.substr(region).encode(encoding))
output = StringIO()
PythonTidy.tidy_up(source, output)
- view.replace(edit, region, output.getvalue().decode(view.encoding()))
+ view.replace(edit, region, output.getvalue().decode(encoding))

0 comments on commit a350b4a

Please sign in to comment.
Something went wrong with that request. Please try again.