update to work with lsp definition format

master
Brad Cornes 2019-01-26 01:00:33 +00:00
parent b21c42e638
commit acbc5a203f
1 changed files with 9 additions and 5 deletions

View File

@ -21,7 +21,8 @@ import {
import { import {
LanguageClient, LanguageClient,
LanguageClientOptions, LanguageClientOptions,
TransportKind TransportKind,
Location
} from 'vscode-languageclient' } from 'vscode-languageclient'
import { createTreeView } from './treeView' import { createTreeView } from './treeView'
@ -137,11 +138,14 @@ export async function activate(context: ExtensionContext) {
}) })
client.onNotification( client.onNotification(
'tailwindcss/foundDefinition', 'tailwindcss/foundDefinition',
(configPath, pos) => { ({ uri, range }: Location) => {
Workspace.openTextDocument(configPath).then((doc: TextDocument) => { Workspace.openTextDocument(uri.replace(/^file:\/\//, '')).then((doc: TextDocument) => {
Window.showTextDocument(doc).then((editor: TextEditor) => { Window.showTextDocument(doc).then((editor: TextEditor) => {
let start = new Position(pos.start.line, pos.start.character) let start = new Position(
let end = new Position(pos.end.line, pos.end.character) range.start.line,
range.start.character
)
let end = new Position(range.end.line, range.end.character)
editor.revealRange( editor.revealRange(
new Range(start, end), new Range(start, end),
TextEditorRevealType.InCenter TextEditorRevealType.InCenter