Skip to content

Commit 638e80a

Browse files
committed
further simplify getting next todo state
1 parent 1e2d3cd commit 638e80a

File tree

1 file changed

+3
-11
lines changed

1 file changed

+3
-11
lines changed

ftplugin/orgmode/plugins/Todo.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,8 @@ def find_current_todo_state(current, all_states, stop=0):
136136
dir = -1
137137
# work only with top level index
138138
if next_set:
139-
# there was no todo state return one based on direction
140-
if ci is None:
141-
if direction == Direction.FORWARD:
142-
echom("Using set: %s" % str(all_states[0]))
143-
return split_access_key(flatten_list(all_states[0])[0])[0]
144-
else:
145-
echom("Using set: %s" % str(all_states[-1]))
146-
return split_access_key(flatten_list(all_states[-1])[0])[0]
147-
ind = (ci[0] + dir) % len(all_states)
139+
top_set = ci[0] if ci is not None else 0
140+
ind = (top_set + dir) % len(all_states)
148141
echom("Using set: %s" % str(all_states[ind]))
149142
# NOTE: List must be flatten because todo states can be empty, this
150143
# is also valid for above use of flat_list
@@ -156,8 +149,7 @@ def find_current_todo_state(current, all_states, stop=0):
156149
# name
157150
try:
158151
ind = (tmp.index(current_state) + dir) % len(tmp)
159-
except ValueError as e:
160-
# print(e)
152+
except ValueError:
161153
# TODO should this return None like or first todo item?
162154
ind = 0
163155
return tmp[ind]

0 commit comments

Comments
 (0)