Skip to content

Commit

Permalink
Added range modifiers till and tween (#32)
Browse files Browse the repository at this point in the history
* Added range modifiers till and tween

* renamed til two until
  • Loading branch information
AndreasArvidsson authored and pokey committed Jul 24, 2021
1 parent 4373fa5 commit 78d866b
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions src/compound_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,31 @@
@mod.capture(
rule=(
"<user.cursorless_primitive_target> | "
"past <user.cursorless_primitive_target> | "
"<user.cursorless_primitive_target> past <user.cursorless_primitive_target>"
"(past|until|tween) <user.cursorless_primitive_target> | "
"<user.cursorless_primitive_target> (past|until|tween) <user.cursorless_primitive_target>"
)
)
def cursorless_range(m) -> str:
if "past" in m:
end = m[-1]
if m[0] == "past":
start = BASE_TARGET.copy()
else:
start = m.cursorless_primitive_target_list[0]
return {
"type": "range",
"start": start,
"end": end,
}
length = len(m)
if length == 1:
return m[0]

return m[0]
if length == 2:
start = BASE_TARGET.copy()
else:
start = m[0]
modifier = m[-2]
return {
"type": "range",
"start": start,
"end": m[-1],
"excludeStart": modifier == "tween",
"excludeEnd": modifier in ["tween", "until"],
}


@mod.capture(rule=("<user.cursorless_range> (and <user.cursorless_range>)*"))
def cursorless_target(m) -> str:
if len(m.cursorless_range_list) == 1:
return m.cursorless_range
return {
"type": "list",
"elements": m.cursorless_range_list
}
return {"type": "list", "elements": m.cursorless_range_list}

0 comments on commit 78d866b

Please sign in to comment.