jtokoph / auto-detect-indentation

Auto detect indentation of files in Atom
MIT License
39 stars 6 forks source link

Fix `TypeError` exception that was crashing Atom #21

Closed int3h closed 8 years ago

int3h commented 8 years ago

This commit is a workaround for issue atom/atom#12575 in Atom core, which was causing uncaught TypeError: Cannot read property 'screenExtent' of undefined exceptions to be thrown by Atom, breaking it until the program was restarted. auto-detect-indentation was inadvertently triggering this bug, causing it to crash Atom in certain circumstances.

The bug was triggered by passing null to editor.setTabLength(). You can see details of the bug in the discussion at https://github.com/atom/atom/issues/12575 .

This commit changes IndentationManager::setIndentation() to check if indentation.tabLength is null, and to only call editor.setTabLength() if it isn't. I also took the opportunity to make the existing null check of indentation.softTabs to be more idiomatic CoffeeScript.

There should be no other behavior change to auto-detect-indentation aside from not trigger unhandled exceptions in Atom.

dsandstrom commented 8 years ago

Fixes the issue, thanks.