extra TODOs and formatting
This commit is contained in:
parent
4352954991
commit
7bd021e236
|
|
@ -2,6 +2,7 @@ import * as lsp from "vscode-languageserver-protocol";
|
||||||
import { StateEffect, StateField } from "@codemirror/state";
|
import { StateEffect, StateField } from "@codemirror/state";
|
||||||
import { GutterMarker, ViewPlugin, ViewUpdate } from "@codemirror/view";
|
import { GutterMarker, ViewPlugin, ViewUpdate } from "@codemirror/view";
|
||||||
import { LSPPlugin, LSPClientExtension } from "@codemirror/lsp-client";
|
import { LSPPlugin, LSPClientExtension } from "@codemirror/lsp-client";
|
||||||
|
import { OpenFile } from "../filestate";
|
||||||
|
|
||||||
type GutterCodeAction = {
|
type GutterCodeAction = {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,10 +41,19 @@ function jumpToOrigin(view: EditorView, type: { get: typeof getDefinition, capab
|
||||||
plugin.client.withMapping(mapping => type.get(plugin, view.state.selection.main.head).then(async response => {
|
plugin.client.withMapping(mapping => type.get(plugin, view.state.selection.main.head).then(async response => {
|
||||||
if (!response) return
|
if (!response) return
|
||||||
let loc = Array.isArray(response) ? response[0] : response;
|
let loc = Array.isArray(response) ? response[0] : response;
|
||||||
|
// TODO: deal with special characters in pathname
|
||||||
|
// (node_modules/@codemirror is %40codemirror)
|
||||||
const path = new URL(loc.uri).pathname;
|
const path = new URL(loc.uri).pathname;
|
||||||
const target = addEditor(await OpenFile.openFile(path));
|
const target = addEditor(await OpenFile.openFile(path));
|
||||||
const pos = mapping.getMapping(loc.uri) ? mapping.mapPosition(loc.uri, loc.range.start) : plugin.fromPosition(loc.range.start, target.view.state.doc);
|
const pos = mapping.getMapping(loc.uri)
|
||||||
target.view.dispatch({selection: {anchor: pos}, scrollIntoView: true, userEvent: "select.definition"});
|
? mapping.mapPosition(loc.uri, loc.range.start)
|
||||||
|
: plugin.fromPosition(loc.range.start, target.view.state.doc);
|
||||||
|
target.view.dispatch({
|
||||||
|
selection: {anchor: pos},
|
||||||
|
scrollIntoView: true,
|
||||||
|
userEvent: "select.definition",
|
||||||
|
});
|
||||||
|
setTimeout(() => target.focus(), 0);
|
||||||
}, error => plugin.reportError("Find definition failed", error)))
|
}, error => plugin.reportError("Find definition failed", error)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -123,6 +123,7 @@ export function serverDiagnostics(): LSPClientExtension {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: add support for DiagnosticRelatedInformation
|
||||||
file.setDiagnostics(
|
file.setDiagnostics(
|
||||||
params.diagnostics.map((item) => ({
|
params.diagnostics.map((item) => ({
|
||||||
from: file.changes.mapPos(
|
from: file.changes.mapPos(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue