Ejemplo n.º 1
0
def a_word(view, pt, inclusive=True, count=1):
    # type: (...) -> Region
    assert count > 0
    start = current_word_start(view, pt)
    end = pt

    if inclusive:
        end = units.word_starts(view, start, count=count, internal=True)

        # If there is no space at the end of our word text object, include any
        # preceding spaces. (Follows Vim behavior.)
        if (not view.substr(end - 1).isspace()
                and view.substr(start - 1).isspace()):
            start = utils.previous_non_white_space_char(
                view, start - 1, white_space=' \t') + 1

        # Vim does some inconsistent stuff here...
        if count > 1 and view.substr(end) == '\n':
            end += 1

        return Region(start, end)

    for x in range(count):
        end = current_word_end(view, end)

    return Region(start, end)
Ejemplo n.º 2
0
def _a_word(view, pt: int, inclusive: bool = True, count: int = 1) -> Region:
    assert count > 0
    start = current_word_start(view, pt)
    end = pt

    if inclusive:
        end = word_starts(view, start, count=count, internal=True)

        # If there is no space at the end of our word text object, include any
        # preceding spaces. (Follows Vim behavior.)
        if (not view.substr(end - 1).isspace() and view.substr(start - 1).isspace()):
            start = prev_non_blank(view, start - 1) + 1

        # Vim does some inconsistent stuff here...
        if count > 1 and view.substr(end) == '\n':
            end += 1

        return Region(start, end)

    for x in range(count):
        end = current_word_end(view, end)

    return Region(start, end)