Document.wordRangeAt

Returns the word range at a given byte position.

  1. TextRange wordRangeAt(Position position)
  2. size_t[2] wordRangeAt(size_t bytes)
    struct Document
    const
    size_t[2]
    wordRangeAt
    (
    size_t bytes
    )

Examples

Document d;
d.setContent(`void main() { writeln("hello world"); }`);
assert(d.wordRangeAt(0) == [0, 4]);
assert(d.wordRangeAt(3) == [0, 4]);
assert(d.wordRangeAt(4) == [0, 4]);
assert(d.wordRangeAt(5) == [5, 9]);
assert(d.wordRangeAt(9) == [5, 9]);
assert(d.wordRangeAt(10) == [10, 10]);
assert(d.wordRangeAt(14) == [14, 21]);
assert(d.wordRangeAt(20) == [14, 21]);
assert(d.wordRangeAt(21) == [14, 21]);
assert(d.wordRangeAt(23) == [23, 28]);
assert(d.wordRangeAt(27) == [23, 28]);
assert(d.wordRangeAt(28) == [23, 28]);
assert(d.wordRangeAt(29) == [29, 34]);
assert(d.wordRangeAt(30) == [29, 34]);
assert(d.wordRangeAt(34) == [29, 34]);

Meta