@jiminp/tooltool
    Preparing search index...

    Function getRowCol

    • Calculates the row and column of a UTF-16 code-unit index for diagnostic locations.

      Parameters

      • s: string

        The string.

      • ind: number

        Zero-based integer index; s.length addresses the position after the text.

      • Optionalpretty: false

        If true, returns 1-based "row:col"; otherwise 0-based tuple.

      Returns RowCol

      [row, col] tuple or "row:col" string.

      If ind is out of bounds.

      Line breaks are \n only; \r is treated as a regular code unit. Columns count UTF-16 code units, not code points or display cells; tabs are not expanded.

      const text = "hello\nworld";
      getRowCol(text, 0); // [0, 0]
      getRowCol(text, 6); // [1, 0]
      getRowCol(text, 6, true); // "2:1"
    • Calculates the row and column of a UTF-16 code-unit index for diagnostic locations.

      Parameters

      • s: string

        The string.

      • ind: number

        Zero-based integer index; s.length addresses the position after the text.

      • pretty: true

        If true, returns 1-based "row:col"; otherwise 0-based tuple.

      Returns `${number}:${number}`

      [row, col] tuple or "row:col" string.

      If ind is out of bounds.

      Line breaks are \n only; \r is treated as a regular code unit. Columns count UTF-16 code units, not code points or display cells; tabs are not expanded.

      const text = "hello\nworld";
      getRowCol(text, 0); // [0, 0]
      getRowCol(text, 6); // [1, 0]
      getRowCol(text, 6, true); // "2:1"