tailwind-ctp-intellisense/packages/tailwindcss-language-service/src/util/resolveRange.ts

19 lines
532 B
TypeScript
Raw Normal View History

import type { Range } from 'vscode-languageserver'
2020-08-12 17:45:36 +00:00
export function resolveRange(range: Range, relativeTo?: Range) {
return {
start: {
line: (relativeTo?.start.line || 0) + range.start.line,
character:
(range.end.line === 0 ? relativeTo?.start.character || 0 : 0) +
range.start.character,
},
end: {
line: (relativeTo?.start.line || 0) + range.end.line,
character:
(range.end.line === 0 ? relativeTo?.start.character || 0 : 0) +
range.end.character,
},
}
}