snapWideBounds static method

(int, int) snapWideBounds(
  1. List<String> chars,
  2. int rowOffset,
  3. int colStart,
  4. int colEnd, {
  5. int minCol = 0,
  6. required int maxCol,
})

Snaps (colStart, colEnd) outward across wide-grapheme continuation ("") cells within [minCol, maxCol].

Implementation

static (int, int) snapWideBounds(
  List<String> chars,
  int rowOffset,
  int colStart,
  int colEnd, {
  int minCol = 0,
  required int maxCol,
}) {
  final snappedStart =
      colStart > minCol && chars[rowOffset + colStart].isEmpty
      ? colStart - 1
      : colStart;
  final snappedEnd = colEnd < maxCol && chars[rowOffset + colEnd + 1].isEmpty
      ? colEnd + 1
      : colEnd;
  return (snappedStart, snappedEnd);
}