示例#1
0
def test_kak_state():
    kcr = FakeKcr(
        get_dict={"buffile": "/home/kakuser/abc.txt", "selection_desc": "101.1,377.9"}
    )
    state = kak.get_state(kcr)
    assert state.buffer_path == "/home/kakuser/abc.txt"
    assert state.selection.range == line_range.LineRange(101, 377)
示例#2
0
 def __init__(self, selection_desc: str) -> None:
     """Parse a selction description from kakoune"""
     anchor_pos, cursor_pos = selection_desc.split(",")
     anchor_line = int(anchor_pos.split(".")[0])
     cursor_line = int(cursor_pos.split(".")[0])
     logging.debug(f"anchor at {anchor_line}; cursor at {cursor_line}")
     self._line_range = line_range.LineRange(min(anchor_line, cursor_line),
                                             max(anchor_line, cursor_line))
示例#3
0
def test_parse_backwards_selection():
    input_str = "50.20,29.99"
    selection = kak.SelectionDescription(input_str)
    assert selection.range == line_range.LineRange(29, 50)
示例#4
0
def test_parse_multiline_selection():
    input_str = "1.1,99.100"
    selection = kak.SelectionDescription(input_str)
    assert selection.range == line_range.LineRange(1, 99)
示例#5
0
def test_parse_single_width():
    input_str = "42.18,42.18"
    selection = kak.SelectionDescription(input_str)
    assert selection.range == line_range.LineRange(42, 42)
示例#6
0
def test_single_line_range():
    lr = line_range.LineRange(10, 10)
    assert str(lr) == "L10"
示例#7
0
def test_line_range_not_equal_other_objects():
    assert line_range.LineRange(1, 2) != "abc"
示例#8
0
def test_line_range_inequality():
    assert line_range.LineRange(1001, 7000) != line_range.LineRange(1, 2)
示例#9
0
def test_line_range_equality():
    assert line_range.LineRange(2, 8) == line_range.LineRange(2, 8)
示例#10
0
def test_line_range_start_less_than_one():
    with pytest.raises(ValueError):
        line_range.LineRange(0, 7)
示例#11
0
def test_line_range_start_greater_than_stop():
    with pytest.raises(ValueError):
        line_range.LineRange(8, 7)
示例#12
0
def test_multiple_line_range():
    lr = line_range.LineRange(7, 99)
    assert str(lr) == "L7-L99"