nvarner / typst-lsp

A brand-new language server for Typst, plus a VS Code extension
MIT License
1.15k stars 78 forks source link

LSP Crash: thread 'main' panicked at 'span should be in source since we got it using the span' #261

Closed KagaJiankui closed 10 months ago

KagaJiankui commented 10 months ago

Issue

Encountered LSP crash similar to #232 on version 0.9.4 (after merged fixes before 0.9.4). When typing an funtion name, the incomplete and undefined input triggered the LSP to panic.

// function name: #pagebreak()

#p // triggers panic
#pa // triggers panic
#pag // triggers panic
... // anything other than `#pagebreak()` immediately make the LSP to panic even before I can input the complete name

Logs

Sample Code

#set text(
  font: "LXGW WenKai",
  size: 14pt,
  lang: "zh",
)

123123

#pagebreak() //LSP crashes along with the keystrokes. One keystroke one panic in the log. After five panickes, the LSP doesn't restart accordingly.

123456

#pag //thread 'main' panicked at 'span should be in source since we got it using the span', src\lsp_typst_boundary.rs:240:14

Verbose Log

[Trace - 23:42:15] Sending notification 'initialized'.
Params: {}

[Trace - 23:42:15] Received notification 'window/logMessage'.
Params: {
    "message": "src\\workspace\\package\\external\\manager.rs:48 { message = got user external package directory; user = LocalProvider { root: \"C:\\\\Users\\\\Falke\\\\AppData\\\\Roaming\\\\typst/packages/\" }; }",
    "type": 3
}

[Info  - 23:42:15] src\workspace\package\external\manager.rs:48 { message = got user external package directory; user = LocalProvider { root: "C:\\Users\\Falke\\AppData\\Roaming\\typst/packages/" }; }
[Trace - 23:42:15] Received notification 'window/logMessage'.
Params: {
    "message": "src\\workspace\\package\\external\\manager.rs:58 { message = got external package cache; cache = LocalProvider { root: \"C:\\\\Users\\\\Falke\\\\AppData\\\\Local\\\\typst/packages/\" }; }",
    "type": 3
}

[Info  - 23:42:15] src\workspace\package\external\manager.rs:58 { message = got external package cache; cache = LocalProvider { root: "C:\\Users\\Falke\\AppData\\Local\\typst/packages/" }; }
[Trace - 23:42:15] Received notification 'window/logMessage'.
Params: {
    "message": "src\\workspace\\package\\manager.rs:42 { message = initialized package manager; current = {Url { scheme: \"file\", cannot_be_a_base: false, username: \"\", password: None, host: None, port: None, path: \"/d%3A/%E6%96%87\", query: None, fragment: None }: Package { root: \"file:///d%3A/%E6%96%87\" }, Url { scheme: \"file\", cannot_be_a_base: false, username: \"\", password: None, host: None, port: None, path: \"/d%3A/%E6%96%87/Falken%28typst%29\", query: None, fragment: None }: Package { root: \"file:///d%3A/%E6%96%87/Falken%28typst%29\" }}; external = ExternalPackageManager { providers: [LocalProvider { root: \"C:\\\\Users\\\\Falke\\\\AppData\\\\Roaming\\\\typst/packages/\" }, LocalProvider { root: \"C:\\\\Users\\\\Falke\\\\AppData\\\\Local\\\\typst/packages/\" }], cache: Some(LocalProvider { root: \"C:\\\\Users\\\\Falke\\\\AppData\\\\Local\\\\typst/packages/\" }), repo: Some(RemoteRepoProvider { base_url: Url { scheme: \"https\", cannot_be_a_base: false, username: \"\", password: None, host: Some(Domain(\"packages.typst.org\")), port: None, path: \"/\", query: None, fragment: None }, client: Client { accepts: Accepts, proxies: [Proxy(System({\"https\": http://127.0.0.1:10809, \"http\": http://127.0.0.1:10809}), None)], referer: true, default_headers: {\"accept\": \"*/*\"}, timeout: 30s } }) }; }",
    "type": 3
}

[Info  - 23:42:15] src\workspace\package\manager.rs:42 { message = initialized package manager; current = {Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/d%3A/%E6%96%87", query: None, fragment: None }: Package { root: "file:///d%3A/%E6%96%87" }, Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/d%3A/%E6%96%87/Falken%28typst%29", query: None, fragment: None }: Package { root: "file:///d%3A/%E6%96%87/Falken%28typst%29" }}; external = ExternalPackageManager { providers: [LocalProvider { root: "C:\\Users\\Falke\\AppData\\Roaming\\typst/packages/" }, LocalProvider { root: "C:\\Users\\Falke\\AppData\\Local\\typst/packages/" }], cache: Some(LocalProvider { root: "C:\\Users\\Falke\\AppData\\Local\\typst/packages/" }), repo: Some(RemoteRepoProvider { base_url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("packages.typst.org")), port: None, path: "/", query: None, fragment: None }, client: Client { accepts: Accepts, proxies: [Proxy(System({"https": http://127.0.0.1:10809, "http": http://127.0.0.1:10809}), None)], referer: true, default_headers: {"accept": "*/*"}, timeout: 30s } }) }; }
[Trace - 23:42:15] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ",
        "languageId": "typst",
        "version": 2,
        "text": "#set text(\r\n  font: \"LXGW WenKai\",\r\n  size: 14pt,\r\n  lang: \"zh\",\r\n)\r\n\r\n123123\r\n\r\n#pagebreak()\r\n\r\n123456\r\n\r\n#p //thread 'main' panicked at 'span should be in source since we got it using the span', src\\lsp_typst_boundary.rs:240:14\r\n"
    }
}

[Trace - 23:42:15] Received request 'client/registerCapability - (0)'.
Params: {
    "registrations": [
        {
            "id": "semantic_tokens",
            "method": "textDocument/semanticTokens",
            "registerOptions": {
                "full": {
                    "delta": true
                },
                "legend": {
                    "tokenModifiers": [
                        "strong",
                        "emph",
                        "math"
                    ],
                    "tokenTypes": [
                        "comment",
                        "string",
                        "keyword",
                        "operator",
                        "number",
                        "function",
                        "decorator",
                        "bool",
                        "punct",
                        "escape",
                        "link",
                        "raw",
                        "label",
                        "ref",
                        "heading",
                        "marker",
                        "term",
                        "delim",
                        "pol",
                        "error",
                        "text"
                    ]
                }
            }
        }
    ]
}

[Trace - 23:42:15] Sending response 'client/registerCapability - (0)'. Processing request took 0ms
No result returned.

[Trace - 23:42:15] Sending request 'textDocument/completion - (1)'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ"
    },
    "position": {
        "line": 12,
        "character": 2
    },
    "context": {
        "triggerKind": 1
    }
}

[Trace - 23:42:15] Received request 'client/registerCapability - (1)'.
Params: {
    "registrations": [
        {
            "id": "config",
            "method": "workspace/didChangeConfiguration"
        }
    ]
}

[Trace - 23:42:15] Sending response 'client/registerCapability - (1)'. Processing request took 0ms
No result returned.

[Trace - 23:42:15] Received request 'client/registerCapability - (2)'.
Params: {
    "registrations": [
        {
            "id": "watch_typst_files",
            "method": "workspace/didChangeWatchedFiles",
            "registerOptions": {
                "watchers": [
                    {
                        "globPattern": "**/*"
                    }
                ]
            }
        }
    ]
}

[Trace - 23:42:15] Sending response 'client/registerCapability - (2)'. Processing request took 0ms
No result returned.

[Trace - 23:42:15] Sending request 'textDocument/documentSymbol - (2)'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ"
    }
}

[Trace - 23:42:15] Received response 'textDocument/completion - (1)' in 3ms.
Result: [
    {
        "detail": "Aligns content horizontally and vertically.",
        "insertText": "align(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "align"
    },
    {
        "detail": "Converts a value to an array.",
        "insertText": "array(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "array"
    },
    {
        "detail": "Ensures that a condition is fulfilled.",
        "insertText": "assert(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "assert"
    },
    {
        "detail": "A bibliography / reference listing.",
        "insertText": "bibliography(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "bibliography"
    },
    {
        "detail": "A block-level container.",
        "insertText": "block(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "block"
    },
    {
        "detail": "An inline-level container that sizes content.",
        "insertText": "box(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "box"
    },
    {
        "detail": "Converts a value to bytes.",
        "insertText": "bytes(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "bytes"
    },
    {
        "detail": "<module calc>",
        "insertTextFormat": 2,
        "kind": 21,
        "label": "calc"
    },
    {
        "detail": "A circle with optional content.",
        "insertText": "circle(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "circle"
    },
    {
        "detail": "Cite a work from the bibliography.",
        "insertText": "cite(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "cite"
    },
    {
        "detail": "Creates a CMYK color.",
        "insertText": "cmyk(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "cmyk"
    },
    {
        "detail": "Forces a column break.",
        "insertText": "colbreak(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "colbreak"
    },
    {
        "detail": "<module color>",
        "insertTextFormat": 2,
        "kind": 21,
        "label": "color"
    },
    {
        "detail": "Separates a region into multiple equally sized columns.",
        "insertText": "columns(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "columns"
    },
    {
        "detail": "Counts through pages, elements, and more.",
        "insertText": "counter(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "counter"
    },
    {
        "detail": "Reads structured data from a CSV file.",
        "insertText": "csv(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "csv"
    },
    {
        "detail": "Creates a new datetime.",
        "insertText": "datetime(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "datetime"
    },
    {
        "detail": "The root element of a document and its metadata.",
        "insertText": "document(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "document"
    },
    {
        "detail": "An ellipse with optional content.",
        "insertText": "ellipse(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "ellipse"
    },
    {
        "detail": "<module emoji>",
        "insertTextFormat": 2,
        "kind": 21,
        "label": "emoji"
    },
    {
        "detail": "Emphasizes content by setting it in italics.",
        "insertText": "emph(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "emph"
    },
    {
        "detail": "A numbered list.",
        "insertText": "enum(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "enum"
    },
    {
        "detail": "Evaluates a string as Typst code.",
        "insertText": "eval(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "eval"
    },
    {
        "detail": "A figure with an optional caption.",
        "insertText": "figure(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "figure"
    },
    {
        "detail": "Converts a value to a float.",
        "insertText": "float(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "float"
    },
    {
        "detail": "A footnote.",
        "insertText": "footnote(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "footnote"
    },
    {
        "detail": "Arranges content in a grid.",
        "insertText": "grid(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "grid"
    },
    {
        "detail": "Inserts horizontal spacing into a paragraph.",
        "insertText": "h(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "h"
    },
    {
        "detail": "A section heading.",
        "insertText": "heading(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "heading"
    },
    {
        "detail": "Hides content without affecting layout.",
        "insertText": "hide(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "hide"
    },
    {
        "detail": "A raster or vector graphic.",
        "insertText": "image(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "image"
    },
    {
        "detail": "Converts a value to an integer.",
        "insertText": "int(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "int"
    },
    {
        "detail": "Reads structured data from a JSON file.",
        "insertText": "json(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "json"
    },
    {
        "detail": "Creates a label from a string.",
        "insertText": "label(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "label"
    },
    {
        "detail": "Provides access to the current outer container's (or page's, if none) size\n(width and height).",
        "insertText": "layout(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "layout"
    },
    {
        "detail": "A line from one point to another.",
        "insertText": "line(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "line"
    },
    {
        "detail": "Inserts a line break.",
        "insertText": "linebreak(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "linebreak"
    },
    {
        "detail": "Links to a URL or a location in the document.",
        "insertText": "link(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "link"
    },
    {
        "detail": "A bullet list.",
        "insertText": "list(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "list"
    },
    {
        "detail": "Provides access to the location of content.",
        "insertText": "locate(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "locate"
    },
    {
        "detail": "Creates blind text.",
        "insertText": "lorem(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "lorem"
    },
    {
        "detail": "Converts text or content to lowercase.",
        "insertText": "lower(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "lower"
    },
    {
        "detail": "Creates a grayscale color.",
        "insertText": "luma(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "luma"
    },
    {
        "detail": "<module math>",
        "insertTextFormat": 2,
        "kind": 21,
        "label": "math"
    },
    {
        "detail": "Measures the layouted size of content.",
        "insertText": "measure(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "measure"
    },
    {
        "detail": "Exposes a value to the query system without producing visible content.",
        "insertText": "metadata(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "metadata"
    },
    {
        "detail": "Moves content without affecting layout.",
        "insertText": "move(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "move"
    },
    {
        "detail": "Applies a numbering to a sequence of numbers.",
        "insertText": "numbering(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "numbering"
    },
    {
        "detail": "A table of contents, figures, or other elements.",
        "insertText": "outline(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "outline"
    },
    {
        "detail": "Adds a line over text.",
        "insertText": "overline(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "overline"
    },
    {
        "detail": "Adds spacing around content.",
        "insertText": "pad(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "pad"
    },
    {
        "detail": "Layouts its child onto one or multiple pages.",
        "insertText": "page(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "page"
    },
    {
        "detail": "A manual page break.",
        "insertText": "pagebreak(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "pagebreak"
    },
    {
        "detail": "Fails with an error.",
        "insertText": "panic(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "panic"
    },
    {
        "detail": "Arranges text, spacing and inline-level elements into a paragraph.",
        "insertText": "par(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "par"
    },
    {
        "detail": "A paragraph break.",
        "insertText": "parbreak(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "parbreak"
    },
    {
        "detail": "A path through a list of points, connected by Bezier curves.",
        "insertText": "path(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "path"
    },
    {
        "detail": "Places content at an absolute position.",
        "insertText": "place(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "place"
    },
    {
        "detail": "A closed polygon.",
        "insertText": "polygon(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "polygon"
    },
    {
        "detail": "Finds elements in the document.",
        "insertText": "query(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "query"
    },
    {
        "detail": "Creates an array consisting of consecutive integers.",
        "insertText": "range(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "range"
    },
    {
        "detail": "Raw text with optional syntax highlighting.",
        "insertText": "raw(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "raw"
    },
    {
        "detail": "Reads plain text or data from a file.",
        "insertText": "read(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "read"
    },
    {
        "detail": "A rectangle with optional content.",
        "insertText": "rect(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "rect"
    },
    {
        "detail": "A reference to a label or bibliography.",
        "insertText": "ref(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "ref"
    },
    {
        "detail": "Creates a regular expression from a string.",
        "insertText": "regex(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "regex"
    },
    {
        "detail": "Repeats content to the available space.",
        "insertText": "repeat(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "repeat"
    },
    {
        "detail": "Returns the string representation of a value.",
        "insertText": "repr(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "repr"
    },
    {
        "detail": "Creates an RGB(A) color.",
        "insertText": "rgb(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "rgb"
    },
    {
        "detail": "Rotates content without affecting layout.",
        "insertText": "rotate(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "rotate"
    },
    {
        "detail": "Scales content without affecting layout.",
        "insertText": "scale(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "scale"
    },
    {
        "detail": "Turns a value into a selector.",
        "insertText": "selector(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "selector"
    },
    {
        "detail": "Displays text in small capitals.",
        "insertText": "smallcaps(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "smallcaps"
    },
    {
        "detail": "A language-aware quote that reacts to its context.",
        "insertText": "smartquote(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "smartquote"
    },
    {
        "detail": "A square with optional content.",
        "insertText": "square(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "square"
    },
    {
        "detail": "Arranges content and spacing horizontally or vertically.",
        "insertText": "stack(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "stack"
    },
    {
        "detail": "Manages stateful parts of your document.",
        "insertText": "state(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "state"
    },
    {
        "detail": "Converts a value to a string.",
        "insertText": "str(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "str"
    },
    {
        "detail": "Strikes through text.",
        "insertText": "strike(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "strike"
    },
    {
        "detail": "Strongly emphasizes content by increasing the font weight.",
        "insertText": "strong(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "strong"
    },
    {
        "detail": "Provides access to active styles.",
        "insertText": "style(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "style"
    },
    {
        "detail": "Renders text in subscript.",
        "insertText": "sub(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "sub"
    },
    {
        "detail": "Renders text in superscript.",
        "insertText": "super(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "super"
    },
    {
        "detail": "<module sym>",
        "insertTextFormat": 2,
        "kind": 21,
        "label": "sym"
    },
    {
        "detail": "Creates a custom symbol with modifiers.",
        "insertText": "symbol(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "symbol"
    },
    {
        "detail": "A table of items.",
        "insertText": "table(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "table"
    },
    {
        "detail": "A list of terms and their descriptions.",
        "insertText": "terms(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "terms"
    },
    {
        "detail": "Customizes the look and layout of text in a variety of ways.",
        "insertText": "text(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "text"
    },
    {
        "detail": "Reads structured data from a TOML file.",
        "insertText": "toml(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "toml"
    },
    {
        "detail": "Determines the type of a value.",
        "insertText": "type(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "type"
    },
    {
        "detail": "Underlines text.",
        "insertText": "underline(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "underline"
    },
    {
        "detail": "Converts text or content to uppercase.",
        "insertText": "upper(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "upper"
    },
    {
        "detail": "Inserts vertical spacing into a flow of blocks.",
        "insertText": "v(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "v"
    },
    {
        "detail": "Reads structured data from an XML file.",
        "insertText": "xml(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "xml"
    },
    {
        "detail": "Reads structured data from a YAML file.",
        "insertText": "yaml(${1:})",
        "insertTextFormat": 2,
        "kind": 3,
        "label": "yaml"
    },
    {
        "detail": "Evaluates a function.",
        "insertText": "${1:function}(${2:arguments})[${3:body}]",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "function call"
    },
    {
        "detail": "Inserts a nested code block.",
        "insertText": "{ ${1:} }",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "code block"
    },
    {
        "detail": "Switches into markup mode.",
        "insertText": "[${1:content}]",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "content block"
    },
    {
        "detail": "Sets style properties on an element.",
        "insertText": "set ${1:}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "set rule"
    },
    {
        "detail": "Redefines the look of an element.",
        "insertText": "show ${1:}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "show rule"
    },
    {
        "detail": "Transforms everything that follows.",
        "insertText": "show: ${1:}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "show rule (everything)"
    },
    {
        "detail": "Saves a value in a variable.",
        "insertText": "let ${1:name} = ${2:value}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "let binding"
    },
    {
        "detail": "Defines a function.",
        "insertText": "let ${1:name}(${2:params}) = ${3:output}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "let binding (function)"
    },
    {
        "detail": "Computes or inserts something conditionally.",
        "insertText": "if ${1:1 < 2} {\n\t${2:}\n}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "if conditional"
    },
    {
        "detail": "Computes or inserts different things based on a condition.",
        "insertText": "if ${1:1 < 2} {\n\t${2:}\n} else {\n\t${3:}\n}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "if-else conditional"
    },
    {
        "detail": "Computes or inserts something while a condition is met.",
        "insertText": "while ${1:1 < 2} {\n\t${2:}\n}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "while loop"
    },
    {
        "detail": "Computes or inserts something for each value in a collection.",
        "insertText": "for ${1:value} in ${2:(1, 2, 3)} {\n\t${3:}\n}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "for loop"
    },
    {
        "detail": "Computes or inserts something for each key and value in a collection.",
        "insertText": "for (${1:key}, ${2:value}) in ${3:(a: 1, b: 2)} {\n\t${4:}\n}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "for loop (with key)"
    },
    {
        "detail": "Exits early from a loop.",
        "insertText": "break",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "break"
    },
    {
        "detail": "Continues with the next iteration of a loop.",
        "insertText": "continue",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "continue"
    },
    {
        "detail": "Returns early from a function.",
        "insertText": "return ${1:output}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "return"
    },
    {
        "detail": "Imports variables from another file.",
        "insertText": "import \"${1:file}.typ\": ${2:items}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "import (file)"
    },
    {
        "detail": "Imports variables from another file.",
        "insertText": "import \"@${1:}\": ${2:items}",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "import (package)"
    },
    {
        "detail": "Includes content from another file.",
        "insertText": "include \"${1:file}.typ\"",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "include (file)"
    },
    {
        "detail": "Includes content from another file.",
        "insertText": "include \"@${1:}\"",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "include (package)"
    },
    {
        "detail": "Creates a sequence of values.",
        "insertText": "(${1:1, 2, 3})",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "array literal"
    },
    {
        "detail": "Creates a mapping from names to value.",
        "insertText": "(${1:a: 1, b: 2})",
        "insertTextFormat": 2,
        "kind": 15,
        "label": "dictionary literal"
    }
]

[Trace - 23:42:15] Received notification 'window/logMessage'.
Params: {
    "message": "src\\server\\lsp.rs:185 { message = server initialized; }",
    "type": 3
}

[Info  - 23:42:15] src\server\lsp.rs:185 { message = server initialized; }
[Trace - 23:42:15] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "diagnostics": [
        {
            "message": "unknown variable: p",
            "range": {
                "end": {
                    "character": 1,
                    "line": 12
                },
                "start": {
                    "character": 1,
                    "line": 12
                }
            },
            "severity": 1,
            "source": "typst"
        }
    ],
    "uri": "file:///d%3A/%E6%96%87/Falken(typst)/test.typ"
}

[Trace - 23:42:15] Received response 'textDocument/documentSymbol - (2)' in 4ms.
Result: []

[Trace - 23:42:15] Sending request 'textDocument/documentSymbol - (3)'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ"
    }
}

[Trace - 23:42:15] Received response 'textDocument/documentSymbol - (3)' in 1ms.
Result: []

[Trace - 23:42:15] Sending request 'textDocument/semanticTokens/full - (4)'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ"
    }
}

[Trace - 23:42:15] Sending request 'textDocument/semanticTokens/full - (5)'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ"
    }
}

[Trace - 23:42:15] Sending request 'textDocument/semanticTokens/full - (6)'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ"
    }
}

[Trace - 23:42:15] Sending request 'textDocument/semanticTokens/full - (7)'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ"
    }
}

[Trace - 23:42:15] Received response 'textDocument/semanticTokens/full - (4)' in 1ms.
Result: {
    "data": [
        0,
        0,
        1,
        2,
        0,
        0,
        1,
        3,
        2,
        0,
        0,
        3,
        1,
        20,
        0,
        0,
        1,
        4,
        5,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        13,
        1,
        0,
        0,
        13,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        4,
        4,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        4,
        1,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        2,
        20,
        0,
        1,
        0,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        2,
        0,
        6,
        20,
        0,
        0,
        6,
        4,
        20,
        0,
        2,
        0,
        1,
        5,
        0,
        0,
        1,
        9,
        5,
        0,
        0,
        9,
        1,
        8,
        0,
        0,
        1,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        2,
        0,
        6,
        20,
        0,
        0,
        6,
        4,
        20,
        0,
        2,
        0,
        1,
        18,
        0,
        0,
        1,
        1,
        18,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        119,
        0,
        0,
        0,
        119,
        2,
        20,
        0
    ],
    "resultId": "0"
}

[Trace - 23:42:15] Received response 'textDocument/semanticTokens/full - (5)' in 2ms.
Result: {
    "data": [
        0,
        0,
        1,
        2,
        0,
        0,
        1,
        3,
        2,
        0,
        0,
        3,
        1,
        20,
        0,
        0,
        1,
        4,
        5,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        13,
        1,
        0,
        0,
        13,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        4,
        4,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        4,
        1,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        2,
        20,
        0,
        1,
        0,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        2,
        0,
        6,
        20,
        0,
        0,
        6,
        4,
        20,
        0,
        2,
        0,
        1,
        5,
        0,
        0,
        1,
        9,
        5,
        0,
        0,
        9,
        1,
        8,
        0,
        0,
        1,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        2,
        0,
        6,
        20,
        0,
        0,
        6,
        4,
        20,
        0,
        2,
        0,
        1,
        18,
        0,
        0,
        1,
        1,
        18,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        119,
        0,
        0,
        0,
        119,
        2,
        20,
        0
    ],
    "resultId": "1"
}

[Trace - 23:42:15] Received response 'textDocument/semanticTokens/full - (6)' in 2ms.
Result: {
    "data": [
        0,
        0,
        1,
        2,
        0,
        0,
        1,
        3,
        2,
        0,
        0,
        3,
        1,
        20,
        0,
        0,
        1,
        4,
        5,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        13,
        1,
        0,
        0,
        13,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        4,
        4,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        4,
        1,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        2,
        20,
        0,
        1,
        0,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        2,
        0,
        6,
        20,
        0,
        0,
        6,
        4,
        20,
        0,
        2,
        0,
        1,
        5,
        0,
        0,
        1,
        9,
        5,
        0,
        0,
        9,
        1,
        8,
        0,
        0,
        1,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        2,
        0,
        6,
        20,
        0,
        0,
        6,
        4,
        20,
        0,
        2,
        0,
        1,
        18,
        0,
        0,
        1,
        1,
        18,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        119,
        0,
        0,
        0,
        119,
        2,
        20,
        0
    ],
    "resultId": "2"
}

[Trace - 23:42:15] Received response 'textDocument/semanticTokens/full - (7)' in 2ms.
Result: {
    "data": [
        0,
        0,
        1,
        2,
        0,
        0,
        1,
        3,
        2,
        0,
        0,
        3,
        1,
        20,
        0,
        0,
        1,
        4,
        5,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        13,
        1,
        0,
        0,
        13,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        4,
        4,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        1,
        2,
        4,
        18,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        4,
        1,
        0,
        0,
        4,
        1,
        8,
        0,
        0,
        1,
        2,
        20,
        0,
        1,
        0,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        2,
        0,
        6,
        20,
        0,
        0,
        6,
        4,
        20,
        0,
        2,
        0,
        1,
        5,
        0,
        0,
        1,
        9,
        5,
        0,
        0,
        9,
        1,
        8,
        0,
        0,
        1,
        1,
        8,
        0,
        0,
        1,
        4,
        20,
        0,
        2,
        0,
        6,
        20,
        0,
        0,
        6,
        4,
        20,
        0,
        2,
        0,
        1,
        18,
        0,
        0,
        1,
        1,
        18,
        0,
        0,
        1,
        1,
        20,
        0,
        0,
        1,
        119,
        0,
        0,
        0,
        119,
        2,
        20,
        0
    ],
    "resultId": "3"
}

[Trace - 23:42:15] Sending notification 'textDocument/didChange'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ",
        "version": 3
    },
    "contentChanges": [
        {
            "range": {
                "start": {
                    "line": 12,
                    "character": 2
                },
                "end": {
                    "line": 12,
                    "character": 2
                }
            },
            "rangeLength": 0,
            "text": "a"
        }
    ]
}

thread 'main' panicked at 'span should be in source since we got it using the span', src\lsp_typst_boundary.rs:240:14
stack backtrace:
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
[Trace - 23:42:16] Sending request 'textDocument/documentSymbol - (8)'.
Params: {
    "textDocument": {
        "uri": "file:///d%3A/%E6%96%87/Falken%28typst%29/test.typ"
    }
}
Enivex commented 10 months ago

Duplicate of https://github.com/nvarner/typst-lsp/issues/241

nvarner commented 10 months ago

Closing in favor of #241