function computeLineLength(line, tabWidth) {
  let extraCharacterCount = 0

  const re = /\t/gu
  let ret
  while ((ret = re.exec(line))) {
    const offset = ret.index
    const totalOffset = offset + extraCharacterCount
    const previousTabStopOffset = tabWidth ? totalOffset % tabWidth : 0
    const spaceCount = tabWidth - previousTabStopOffset
    extraCharacterCount += spaceCount - 1 // -1 for the replaced tab
  }

  return [...line].length + extraCharacterCount
}
Computes the length of a line that may contain tabs. The width of each
tab will be the number of spaces to the next tab stop.
@param {string} line The line.
@param {number} tabWidth The width of each tab stop in spaces.
@returns {number} The computed line length.
@private