diff --git a/mode/c.py b/mode/c.py index 1f52519..24c7854 100644 --- a/mode/c.py +++ b/mode/c.py @@ -95,7 +95,11 @@ MacroGrammar.rules.extend(CGrammar.rules) class CTabber2(tab.StackTabber2): open_tokens = {'delimiter': {'{': '}', '(': ')', '[': ']'}} close_tokens = {'delimiter': {'}': '{', ')': '(', ']': '['}} - control_tokens = {'c.builtin': {'if': 1, 'else': 1, 'while': 1, 'do': 1, 'for': 1}} + # NOTE: we actually need at least two kinds of control tokens: + # an if/else class, and a do/for/while class. this is so we can get + # indenting support for else working correctly. + control_tokens = {'c.builtin': {'if': 1, 'else': 1, 'while': 1, + 'do': 1, 'for': 1}} end_at_eof = False end_at_tokens = {'delimiter': {';': 1}} nocontinue_tokens = {'delimiter': {';': 1, ',': 1}} diff --git a/tab.py b/tab.py index e149f05..56dd758 100644 --- a/tab.py +++ b/tab.py @@ -473,4 +473,4 @@ class StackTabber2(Tabber): if i == start: self._save_curr_level() self._pop_while('continue'); - self._append('control', name, self._get_next_level(), y) + self._append_unless('control', name, self._get_next_level(), y)