Home

tailwind-ctp-intellisense @b79dbfc9f9d243fd489a4b73642c8976f983d84d - 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()
}