eerohele / exalt

A Sublime Text plugin for validating and formatting XML documents
MIT License
22 stars 3 forks source link

`exalt_format` raises errors in console when used in non-xml files #22

Open Jackenmen opened 3 years ago

Jackenmen commented 3 years ago

When used without a selection:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 1088, in run_
    return self.run(edit)
  File "C:\Users\Jakub\AppData\Roaming\Sublime Text 3\Packages\Exalt\impl\plugin.py", line 72, in run
    view.replace(edit, region, formatted)
  File "C:\Program Files\Sublime Text 3\sublime.py", line 837, in replace
    sublime_api.view_replace(self.view_id, edit.edit_token, r, text)
TypeError: String required

When used with a selection:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 1088, in run_
    return self.run(edit)
  File "C:\Users\Jakub\AppData\Roaming\Sublime Text 3\Packages\Exalt\impl\plugin.py", line 103, in run
    xml = self.indent(formatter.format_region(view, region), region)
  File "C:\Users\Jakub\AppData\Roaming\Sublime Text 3\Packages\Exalt\impl\plugin.py", line 96, in indent
    lines = map(partial(self.indent_line, region), xml_string.splitlines())
AttributeError: 'NoneType' object has no attribute 'splitlines'
eerohele commented 3 years ago

Thanks! This issue should be fairly straightforward to fix. I'll try to get to it soon.