Myriad-Dreamin / tinymist

Tinymist [ˈtaɪni mɪst] is an integrated language service for Typst [taɪpst].
https://myriad-dreamin.github.io/tinymist
Apache License 2.0
278 stars 11 forks source link

Weird highlight behavior #334

Closed RungeCC closed 1 week ago

RungeCC commented 2 weeks ago

Describe the bug The following code snippets

#let xxx = n => $#n$
#xxx(1)
Dot't color me!
// #(
This should not be colored!

tinymist highlights them as:

image

Notice that:

Package/Software version:

VSCode version(Help -> About):

Version: 1.90.0
Release: 24158
Commit: cc102f3a62bd35f39ed059b99c5cce90e50a16e2
Date: 2024-06-06T18:33:17.728Z
Electron: 29.4.0
ElectronBuildId: undefined
Chromium: 122.0.6261.156
Node.js: 20.9.0
V8: 12.2.281.27-electron.0
OS: Linux x64 6.6.32

tinymist extension version: v0.11.11. Get it by tinymist --version in terminal.

tinymist 
Build Timestamp:     1980-01-01T00:00:00.000000000Z
Build Git Describe:  VERGEN_IDEMPOTENT_OUTPUT
Commit SHA:          VERGEN_IDEMPOTENT_OUTPUT
Commit Date:         None
Commit Branch:       None
Cargo Target Triple: x86_64-unknown-linux-gnu
Typst Version:       0.11.1

Logs:

tinymist server log(Output Panel -> tinymist): ```plain [2024-06-20T20:14:25Z INFO tinymist] starting generic LSP server: LspArgs { mirror: MirrorArgs { mirror: "", replay: "", }, font: FontArgs { font_paths: [], no_system_fonts: false, }, } [2024-06-20T20:14:25Z INFO tinymist::harness] handling initialize - (0) at Instant { tv_sec: 151236, tv_nsec: 449649812 } [2024-06-20T20:14:25Z INFO tinymist::server::lsp_init] initialized with const_config ConstConfig { position_encoding: Utf16, cfg_change_registration: true, tokens_dynamic_registration: true, tokens_overlapping_token_support: false, tokens_multiline_token_support: false, doc_line_folding_only: true, doc_fmt_dynamic_registration: true } [2024-06-20T20:14:25Z INFO tinymist::server::lsp_init] initialized with config Config { notify_compile_status: false, compile: CompileConfig { roots: ["/home/runge/repos/typ/_"], output_path: "", export_pdf: Auto, root_path: None, font_opts: CompileFontOpts { font_profile_cache_path: "", font_paths: [], no_system_fonts: false }, system_fonts: Some(true), font_paths: [], fonts: OnceCell(Uninit), notify_compile_status: true, periscope_args: None, typst_extra_args: Some(CompileExtraOpts { root_dir: None, entry: None, inputs: {}, font_paths: [] }), preferred_theme: None, has_default_entry_path: false }, semantic_tokens: Enable, formatter: Disable, formatter_print_width: 120 } [2024-06-20T20:14:25Z INFO tinymist::actor::format] formatting thread with config: FormatConfig { mode: Disable, width: 120, } [2024-06-20T20:14:25Z INFO tinymist::server::compiler_init] creating SharedFontResolver with CompileFontOpts { font_profile_cache_path: "", font_paths: [], no_system_fonts: false } [2024-06-20T20:14:25Z INFO tinymist::actor] TypstActor: creating server for primary, entry: Workspace { root: "/home/runge/repos/typ/_", main: None }, inputs: {} [2024-06-20T20:14:25Z INFO tinymist::harness] handled initialize - (0) in 1.38ms [2024-06-20T20:14:25Z INFO tinymist::harness] waiting for initialized notification [2024-06-20T20:14:25Z INFO tinymist::server::lsp] server initialized [2024-06-20T20:14:25Z INFO tinymist::server::lsp] notifying textDocument/didOpen - at Instant { tv_sec: 151236, tv_nsec: 456675721 } [2024-06-20T20:14:25Z INFO tinymist::server::lsp] did open Url { scheme: "file", cannot_be_a_base: false, username: "", password: None, host: None, port: None, path: "/home/runge/repos/typ/_/main.typ", query: None, fragment: None } [2024-06-20T20:14:25Z INFO tinymist::state] create source: "/home/runge/repos/typ/_/main.typ" [2024-06-20T20:14:25Z INFO tinymist::actor::typ_client] the entry file of TypstActor(primary) is changing to Workspace { root: "/home/runge/repos/typ/_", main: Some(/main.typ) } [2024-06-20T20:14:27Z INFO typst_ts_compiler::service::diag::console] /main.typ: compiling ... [2024-06-20T20:14:27Z INFO tinymist::actor::export] RenderActor: document is not ready [2024-06-20T20:14:27Z INFO tinymist::state] file focused[implicit,o]: Some("/home/runge/repos/typ/_/main.typ") [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifing textDocument/didOpen succeeded in 1.04s [2024-06-20T20:14:27Z INFO tinymist::harness] handling workspace/executeCommand - (1) at Instant { tv_sec: 151237, tv_nsec: 499688677 } [2024-06-20T20:14:27Z INFO tinymist::server::lsp] first manual focusing is coming [2024-06-20T20:14:27Z INFO tinymist::harness] handled workspace/executeCommand - (1) in 23.98µs [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/documentColor - (2) at Instant { tv_sec: 151237, tv_nsec: 499733575 } [2024-06-20T20:14:27Z INFO typst_ts_compiler::service::diag::console] /main.typ: Compilation succeeded in 1.720043ms [2024-06-20T20:14:27Z INFO tinymist::actor::editor] received diagnostics from primary: diag(Some(0)) [2024-06-20T20:14:27Z INFO tinymist::actor::typ_server] CompileServerActor: evict compilation cache in 4.492µs [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/documentColor - (2) in 1.69ms [2024-06-20T20:14:27Z INFO typst_ts_compiler::service::diag::console] /main.typ: compiling ... [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/codeAction - (3) at Instant { tv_sec: 151237, tv_nsec: 501446722 } [2024-06-20T20:14:27Z INFO typst_ts_compiler::service::diag::console] /main.typ: Compilation succeeded in 87.104µs [2024-06-20T20:14:27Z INFO tinymist::actor::typ_server] CompileServerActor: evict compilation cache in 934ns [2024-06-20T20:14:27Z INFO tinymist::actor::editor] received diagnostics from primary: diag(Some(0)) [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/codeAction - (3) in 102.48µs [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying $/cancelRequest - at Instant { tv_sec: 151237, tv_nsec: 501557895 } [2024-06-20T20:14:27Z WARN tinymist::server::lsp] unhandled notification: $/cancelRequest [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/codeAction - (4) at Instant { tv_sec: 151237, tv_nsec: 501571613 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/codeAction - (4) in 17.30µs [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying $/cancelRequest - at Instant { tv_sec: 151237, tv_nsec: 501591889 } [2024-06-20T20:14:27Z WARN tinymist::server::lsp] unhandled notification: $/cancelRequest [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/codeAction - (5) at Instant { tv_sec: 151237, tv_nsec: 501597477 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/codeAction - (5) in 12.27µs [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying $/setTrace - at Instant { tv_sec: 151237, tv_nsec: 501612890 } [2024-06-20T20:14:27Z WARN tinymist::server::lsp] unhandled notification: $/setTrace [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying workspace/didChangeConfiguration - at Instant { tv_sec: 151237, tv_nsec: 501616724 } [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifing workspace/didChangeConfiguration succeeded in 22.81µs [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying $/setTrace - at Instant { tv_sec: 151237, tv_nsec: 501641865 } [2024-06-20T20:14:27Z WARN tinymist::server::lsp] unhandled notification: $/setTrace [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying workspace/didChangeConfiguration - at Instant { tv_sec: 151237, tv_nsec: 501647172 } [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifing workspace/didChangeConfiguration succeeded in 8.13µs [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/hover - (6) at Instant { tv_sec: 151237, tv_nsec: 501657355 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/hover - (6) in 20.36µs [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/documentHighlight - (7) at Instant { tv_sec: 151237, tv_nsec: 501680545 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/documentHighlight - (7) in 14.29µs [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying $/cancelRequest - at Instant { tv_sec: 151237, tv_nsec: 501697999 } [2024-06-20T20:14:27Z WARN tinymist::server::lsp] unhandled notification: $/cancelRequest [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/documentSymbol - (8) at Instant { tv_sec: 151237, tv_nsec: 501702416 } [2024-06-20T20:14:27Z INFO tinymist_query::syntax::lexical_hierarchy] lexical hierarchy analysis took 11.822µs [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/documentSymbol - (8) in 34.85µs [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/foldingRange - (9) at Instant { tv_sec: 151237, tv_nsec: 501739930 } [2024-06-20T20:14:27Z INFO tinymist_query::syntax::lexical_hierarchy] lexical hierarchy analysis took 3.537µs [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/foldingRange - (9) in 14.33µs [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/semanticTokens/full - (10) at Instant { tv_sec: 151237, tv_nsec: 501756891 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/semanticTokens/full - (10) in 27.62µs [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/codeLens - (11) at Instant { tv_sec: 151237, tv_nsec: 501787163 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/codeLens - (11) in 37.08µs [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/codeAction - (12) at Instant { tv_sec: 151237, tv_nsec: 501827009 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/codeAction - (12) in 17.82µs [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying $/cancelRequest - at Instant { tv_sec: 151237, tv_nsec: 501847604 } [2024-06-20T20:14:27Z WARN tinymist::server::lsp] unhandled notification: $/cancelRequest [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying $/cancelRequest - at Instant { tv_sec: 151237, tv_nsec: 501852123 } [2024-06-20T20:14:27Z WARN tinymist::server::lsp] unhandled notification: $/cancelRequest [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/codeAction - (13) at Instant { tv_sec: 151237, tv_nsec: 501855534 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/codeAction - (13) in 11.77µs [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying $/cancelRequest - at Instant { tv_sec: 151237, tv_nsec: 501870371 } [2024-06-20T20:14:27Z WARN tinymist::server::lsp] unhandled notification: $/cancelRequest [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/codeAction - (14) at Instant { tv_sec: 151237, tv_nsec: 501877562 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/codeAction - (14) in 11.05µs [2024-06-20T20:14:27Z INFO tinymist::server::lsp] notifying $/cancelRequest - at Instant { tv_sec: 151237, tv_nsec: 501891409 } [2024-06-20T20:14:27Z WARN tinymist::server::lsp] unhandled notification: $/cancelRequest [2024-06-20T20:14:27Z INFO tinymist::server::compiler] new settings applied [2024-06-20T20:14:27Z INFO tinymist::server::lsp] new settings applied [2024-06-20T20:14:27Z INFO tinymist::server::compiler] new settings applied [2024-06-20T20:14:27Z INFO tinymist::server::lsp] new settings applied [2024-06-20T20:14:27Z INFO tinymist::harness] handling textDocument/codeLens - (15) at Instant { tv_sec: 151237, tv_nsec: 621311668 } [2024-06-20T20:14:27Z INFO tinymist::harness] handled textDocument/codeLens - (15) in 130.31µs [2024-06-20T20:14:28Z INFO tinymist::harness] handling textDocument/codeAction - (16) at Instant { tv_sec: 151238, tv_nsec: 595495054 } [2024-06-20T20:14:28Z INFO tinymist::harness] handled textDocument/codeAction - (16) in 82.70µs [2024-06-20T20:14:28Z INFO tinymist::harness] handling textDocument/documentSymbol - (17) at Instant { tv_sec: 151238, tv_nsec: 596317991 } [2024-06-20T20:14:28Z INFO tinymist_query::syntax::lexical_hierarchy] lexical hierarchy analysis took 10.673µs [2024-06-20T20:14:28Z INFO tinymist::harness] handled textDocument/documentSymbol - (17) in 32.25µs [2024-06-20T20:14:28Z INFO tinymist::server::lsp] notifying $/setTrace - at Instant { tv_sec: 151238, tv_nsec: 616854032 } [2024-06-20T20:14:28Z WARN tinymist::server::lsp] unhandled notification: $/setTrace [2024-06-20T20:14:28Z INFO tinymist::server::lsp] notifying workspace/didChangeConfiguration - at Instant { tv_sec: 151238, tv_nsec: 616873195 } [2024-06-20T20:14:28Z INFO tinymist::server::lsp] notifing workspace/didChangeConfiguration succeeded in 21.59µs [2024-06-20T20:14:28Z INFO tinymist::server::compiler] new settings applied [2024-06-20T20:14:28Z INFO tinymist::server::lsp] new settings applied [2024-06-20T20:14:29Z INFO tinymist::harness] handling textDocument/documentHighlight - (18) at Instant { tv_sec: 151239, tv_nsec: 590170870 } [2024-06-20T20:14:29Z INFO tinymist::harness] handled textDocument/documentHighlight - (18) in 75.55µs [2024-06-20T20:14:29Z INFO tinymist::harness] handling workspace/executeCommand - (19) at Instant { tv_sec: 151239, tv_nsec: 596067130 } [2024-06-20T20:14:29Z INFO tinymist::actor::typ_client] the entry file of TypstActor(primary) is changing to Workspace { root: "/home/runge/repos/typ/_", main: None } [2024-06-20T20:14:29Z INFO tinymist::actor::typ_client] TypstActor: removing diag [2024-06-20T20:14:29Z INFO tinymist::server::lsp] file focused: None [2024-06-20T20:14:29Z INFO tinymist::harness] handled workspace/executeCommand - (19) in 51.43µs [2024-06-20T20:14:29Z INFO tinymist::actor::editor] received diagnostics from primary: diag(None) [2024-06-20T20:14:29Z INFO tinymist::harness] handling workspace/executeCommand - (20) at Instant { tv_sec: 151240, tv_nsec: 210358864 } [2024-06-20T20:14:29Z INFO tinymist::actor::typ_client] the entry file of TypstActor(primary) is changing to Workspace { root: "/home/runge/repos/typ/_", main: Some(/main.typ) } [2024-06-20T20:14:29Z INFO typst_ts_compiler::service::diag::console] /main.typ: compiling ... [2024-06-20T20:14:29Z INFO tinymist::server::lsp] file focused: Some("/home/runge/repos/typ/_/main.typ") [2024-06-20T20:14:29Z INFO tinymist::harness] handled workspace/executeCommand - (20) in 82.69µs [2024-06-20T20:14:29Z INFO typst_ts_compiler::service::diag::console] /main.typ: Compilation succeeded in 68.532µs [2024-06-20T20:14:29Z INFO tinymist::actor::typ_server] CompileServerActor: evict compilation cache in 8.336µs [2024-06-20T20:14:29Z INFO tinymist::actor::editor] received diagnostics from primary: diag(Some(0)) [2024-06-20T20:14:31Z INFO tinymist::harness] handling textDocument/documentHighlight - (21) at Instant { tv_sec: 151241, tv_nsec: 636171609 } [2024-06-20T20:14:31Z INFO tinymist::harness] handled textDocument/documentHighlight - (21) in 74.31µs [2024-06-20T20:14:31Z INFO tinymist::harness] handling workspace/executeCommand - (22) at Instant { tv_sec: 151241, tv_nsec: 641608190 } [2024-06-20T20:14:31Z INFO tinymist::actor::typ_client] the entry file of TypstActor(primary) is changing to Workspace { root: "/home/runge/repos/typ/_", main: None } [2024-06-20T20:14:31Z INFO tinymist::actor::typ_client] TypstActor: removing diag [2024-06-20T20:14:31Z INFO tinymist::server::lsp] file focused: None [2024-06-20T20:14:31Z INFO tinymist::harness] handled workspace/executeCommand - (22) in 47.43µs [2024-06-20T20:14:31Z INFO tinymist::actor::editor] received diagnostics from primary: diag(None) [2024-06-20T20:14:33Z INFO tinymist::harness] handling workspace/executeCommand - (23) at Instant { tv_sec: 151243, tv_nsec: 735122716 } [2024-06-20T20:14:33Z INFO tinymist::actor::typ_client] the entry file of TypstActor(primary) is changing to Workspace { root: "/home/runge/repos/typ/_", main: Some(/main.typ) } [2024-06-20T20:14:33Z INFO typst_ts_compiler::service::diag::console] /main.typ: compiling ... [2024-06-20T20:14:33Z INFO tinymist::server::lsp] file focused: Some("/home/runge/repos/typ/_/main.typ") [2024-06-20T20:14:33Z INFO tinymist::harness] handled workspace/executeCommand - (23) in 76.78µs [2024-06-20T20:14:33Z INFO typst_ts_compiler::service::diag::console] /main.typ: Compilation succeeded in 78.697µs [2024-06-20T20:14:33Z INFO tinymist::actor::editor] received diagnostics from primary: diag(Some(0)) [2024-06-20T20:14:33Z INFO tinymist::actor::typ_server] CompileServerActor: evict compilation cache in 7.156µs [2024-06-20T20:14:33Z INFO tinymist::harness] handling textDocument/documentHighlight - (24) at Instant { tv_sec: 151243, tv_nsec: 741671030 } [2024-06-20T20:14:33Z INFO tinymist::harness] handled textDocument/documentHighlight - (24) in 70.00µs [2024-06-20T20:14:35Z INFO tinymist::harness] handling workspace/executeCommand - (25) at Instant { tv_sec: 151245, tv_nsec: 809685740 } ```

tinymist client log(Help -> Toggle Developer Tools -> Console):

Additional context VSCode color theme Monokai Dimmed, devtool shows that the element of that line is:

<div style="top:92px;height:19px;" class="view-line">
<span>
  <span class="mtk6">This</span><span class="mtk1">&nbsp;</span>
  <span class="mtk6">should</span><span class="mtk1">&nbsp;</span>
  <span class="mtk13">not</span><span class="mtk1">&nbsp;</span>
  <span class="mtk6">be</span><span class="mtk1">&nbsp;</span>
  <span class="mtk6">colored</span><span class="mtk1">!</span>
</span></div>

Possibly related to https://github.com/Myriad-Dreamin/tinymist/issues/126