Home

tailwind-ctp-intellisense @01941f967b13cfb45e3c2fc53126fb137e04d21b - refs - log -
-
https://git.jolheiser.com/tailwind-ctp-intellisense.git
Tailwind intellisense + Catppuccin
tailwind-ctp-intellisense / src / lsp / util / removeRangeFromString.ts
- raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
import { Range } from 'vscode-languageserver'
import lineColumn from 'line-column'

export function removeRangeFromString(str: string, range: Range): string {
  let finder = lineColumn(str + '\n', { origin: 0 })
  let start = finder.toIndex(range.start.line, range.start.character)
  let end = finder.toIndex(range.end.line, range.end.character)
  for (let i = start - 1; i >= 0; i--) {
    if (/\s/.test(str.charAt(i))) {
      start = i
    } else {
      break
    }
  }
  return (str.substr(0, start) + str.substr(end)).trim()
}