add support for better case indentation
--HG-- branch : pmacs2
This commit is contained in:
parent
4ae87e7e2c
commit
7349b13195
9
tab.py
9
tab.py
|
@ -252,6 +252,7 @@ class StackTabber2(Tabber):
|
|||
open_test_tokens = {'delimiter': set(['('])}
|
||||
close_test_tokens = {'delimiter': set([')'])}
|
||||
control_tokens = {'keyword': set(['if', 'else', 'while', 'do', 'for'])}
|
||||
case_tokens = {'keyword': set(['case'])}
|
||||
end_at_eof = True
|
||||
end_at_tokens = {}
|
||||
continue_tokens = {}
|
||||
|
@ -421,6 +422,7 @@ class StackTabber2(Tabber):
|
|||
# block. e.g. else switch() { ... }
|
||||
if t.string in self.close_scope_tokens.get(t.fqname(), empty):
|
||||
self._pop('control')
|
||||
self._pop('case')
|
||||
|
||||
# if we do want implicit continuation, see if we need it.
|
||||
name, s = t.fqname(), t.string
|
||||
|
@ -513,5 +515,10 @@ class StackTabber2(Tabber):
|
|||
if i == start:
|
||||
self._save_curr_level()
|
||||
self._pop_while('continue');
|
||||
#self._append_unless('control', name, self._get_next_level(), y)
|
||||
self._append_unless('pre-control', name, self._get_next_level(), y)
|
||||
elif s in self.case_tokens.get(name, {}):
|
||||
if top is not None and top.name == 'case':
|
||||
self._pop('case')
|
||||
if i == 0:
|
||||
self._save_curr_level()
|
||||
self._append_unless('case', name, self._get_next_level(), y)
|
||||
|
|
Loading…
Reference in New Issue