Bug 509085

Summary: Deno LSP works but doesn't highlight errors
Product: [Applications] kate Reporter: witold
Component: applicationAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: waqar.17a, witold
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Microsoft Windows   
OS: Microsoft Windows   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Screenshot
LSP debug output
cant_reproduce

Description witold 2025-09-03 19:23:32 UTC
Created attachment 184688 [details]
Screenshot

SUMMARY

Deno LSP works (Diagnostics tab display errors and warnings from LSP) but errors are not highlighted in the editor.

STEPS TO REPRODUCE

1. Install Deno executable

2.  Configure Deno LSP:

"lspclient": {
    "servers": {
        "javascript": {
            "command": ["deno", "lsp", "-L", "info"],
            "rootIndicationFileNames": ["deno.json"],
            "highlightingModeRegex": "^JavaScript.*$"
        }
    }
}

OBSERVED RESULT

See summary and the attached screenshot.

EXPECTED RESULT

Errors reported by LSP shoud be highlighted in the editor. For example this works for LSP Python.

SOFTWARE/OS VERSIONS
Windows: Windows 11

ADDITIONAL INFORMATION
I use latest Kate version (nightly).
Comment 1 witold 2025-09-03 22:12:49 UTC
Kate: 25.11.70
KDE Frameworks: 6.17.0
Qt: Using 6.9.1 and built against 6.9.1
Windows 11 Version 24H2
Build ABI: x86_64-little_endian-llp64
Kernel: winnt 10.0.26100
Comment 2 Waqar Ahmed 2025-09-24 04:38:28 UTC
can you collect some logs from deno lsp?
Comment 3 Waqar Ahmed 2025-09-24 04:38:43 UTC
status change
Comment 4 witold 2025-09-28 18:18:32 UTC
(In reply to Waqar Ahmed from comment #2)
> can you collect some logs from deno lsp?

This is lsp log for main.ts file with just "aaa" (which gives "Cannot find name 'aaa'" in Diagnostics tab but do not any error highlighting in the editor):

[18:13:22  LSP Server Log] typescript@C:/Users/admin/test_project
TRACE RS - deno_tower_lsp::codec:157 - <- {
    "jsonrpc": "2.0",
    "method": "textDocument/didChange",
    "params": {
        "contentChanges": [
            {
                "text": "aaa"
            }
        ],
        "textDocument": {
            "uri": "file:///C:/Users/admin/test_project/main.ts",
            "version": 29
        }
    }
}
[18:13:22  LSP Server Log] typescript@C:/Users/admin/test_project
TRACE RS - deno_tower_lsp::codec:157 - <- {
    "id": 33,
    "jsonrpc": "2.0",
    "method": "textDocument/documentSymbol",
    "params": {
        "textDocument": {
            "uri": "file:///C:/Users/admin/test_project/main.ts"
        }
    }
}
DEBUG RS - deno_resolver::workspace:931 - Workspace config generated this import map {
  "imports": {
    "@std/assert": "jsr:@std/assert@1",
    "@std/assert/": "jsr:/@std/assert@1/"
  }
}
DEBUG RS - deno_resolver::workspace:931 - Workspace config generated this import map {
  "imports": {
    "@std/assert": "jsr:@std/assert@1",
    "@std/assert/": "jsr:/@std/assert@1/"
  }
}
DEBUG RS - deno_resolver::workspace:931 - Workspace config generated this import map {
  "imports": {
    "@std/assert": "jsr:@std/assert@1",
    "@std/assert/": "jsr:/@std/assert@1/"
  }
}
DEBUG RS - deno_lint::performance_mark:30 - Linter::collect_diagnostics took 25µs
DEBUG RS - deno_lint::performance_mark:30 - Linter::lint_inner took 135.1µs
DEBUG RS - deno_lint::performance_mark:30 - Linter::lint_with_ast took 145.6µs
[18:13:22  LSP Server Log] typescript@C:/Users/admin/test_project
TRACE RS - deno_tower_lsp::codec:117 - -> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///c%3A/Users/admin/test_project/main.ts","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}},"severity":1,"code":2304,"source":"deno-ts","message":"Cannot find name 'aaa'."}],"version":29}}
TRACE RS - deno_tower_lsp::codec:117 - -> {"jsonrpc":"2.0","result":null,"id":33}
[18:13:23  LSP Server Log] typescript@C:/Users/admin/test_project
TRACE RS - deno_tower_lsp::codec:157 - <- {
    "id": 34,
    "jsonrpc": "2.0",
    "method": "textDocument/semanticTokens/range",
    "params": {
        "range": {
            "end": {
                "character": 3,
                "line": 0
            },
            "start": {
                "character": 0,
                "line": 0
            }
        },
        "textDocument": {
            "uri": "file:///C:/Users/admin/test_project/main.ts"
        }
    }
}
[18:13:23  LSP Server Log] typescript@C:/Users/admin/test_project
DEBUG RS - deno_resolver::workspace:931 - Workspace config generated this import map {
  "imports": {
    "@std/assert": "jsr:@std/assert@1",
    "@std/assert/": "jsr:/@std/assert@1/"
  }
}
TRACE RS - deno_tower_lsp::codec:117 - -> {"jsonrpc":"2.0","result":null,"id":34}
[18:13:41  LSP Server Log] typescript@C:/Users/admin/test_project
TRACE RS - hyper_util::client::legacy::pool:799 - idle interval checking for expired
TRACE RS - hyper_util::client::legacy::pool:492 - idle interval evicting expired for ("https", dl.deno.land)
TRACE RS - h2::proto::connection:268 - connection.state=Open
TRACE RS - h2::codec::framed_write:210 - FramedWrite::buffer; frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }
DEBUG RS - h2::codec::framed_write:213 - send frame=GoAway { error_code: NO_ERROR, last_stream_id: StreamId(0) }
TRACE RS - h2::frame::go_away:60 - encoding GO_AWAY; code=NO_ERROR
[18:13:41  LSP Server Log] typescript@C:/Users/admin/test_project
TRACE RS - h2::codec::framed_write:266 - encoded go_away rem=17
DEBUG RS - h2::proto::connection:435 - Connection::poll; connection error error=GoAway(b"", NO_ERROR, Library)
TRACE RS - h2::proto::connection:444 -     -> already going away
TRACE RS - h2::proto::connection:268 - connection.state=Closing(NO_ERROR, Library)
TRACE RS - h2::proto::connection:297 - connection closing after flush
TRACE RS - h2::codec::framed_write:143 - queued_data_frame=false
TRACE RS - h2::codec::framed_write:159 - flushing buffer
TRACE RS - h2::proto::connection:268 - connection.state=Closed(NO_ERROR, Library)
TRACE RS - h2::proto::streams::streams:854 - Streams::recv_eof
Comment 5 witold 2025-09-29 18:08:11 UTC
Created attachment 185370 [details]
LSP debug output

I figured out how to extend the output buffer so I'm attaching the full LSP log of this behavior.
Comment 6 Waqar Ahmed 2025-09-30 04:38:13 UTC
This looks good:

> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///c%3A/Users/admin/test_project/main.ts","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}},"severity":1,"code":2304,"source":"deno-ts","message":"Cannot find name 'aaa'."}],"version":29}}

So the server seems to be okay. Does Kate print any warnings on the terminal?

I would have suggested changing color themes, but seems like python lsp is working for you.
Comment 7 Waqar Ahmed 2025-09-30 05:01:45 UTC
Created attachment 185385 [details]
cant_reproduce

Can't reproduce with a newly set up deno project.

Used the following config for the lsp:

        "javascript": {
            "command": ["deno", "lsp"],
            "rootIndicationFileNames": ["deno.json"],
            "highlightingModeRegex": "^JavaScript$"
        },
        "typescript": {
            "use": "javascript",
            "highlightingModeRegex": "^TypeScript$"
        },
Comment 8 witold 2025-09-30 05:58:07 UTC
Thank you very much for checking. It doesn't work for me on two different systems (both Windows). I'll investigate this from the OS side. Just confirm you tested it on Linux, right?
Comment 9 witold 2025-09-30 08:11:51 UTC
OK, I see from the screenshot that you tested on Linux. This must be some subtle issue with Deno LSP. I've tested various older versions of Deno, and version 2.2.0, for example, works fine. It doesn't help that Windows isn't the primary platform for both Deno and Kate. Here's an example report from three days ago that Deno LSP stopped working in JetBrain IDE on Windows: https://github.com/denoland/deno/issues/30859. Thanks again for your help, it did help us come to some sort of conclusion :) I'll post an update here if the problem resolves itself in the future (I assume so).
Comment 10 Waqar Ahmed 2025-09-30 08:48:31 UTC
> Just confirm you tested it on Linux, right?

Yes. And I installed deno lsp using the shell helper they provide on their website.

Looking at the logs again,

there is:
>  "uri": "file:///C:/Users/admin/test_project/main.ts"

and when sending diagnostics its percent encoded:

> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///c%3A/Users/admin/test_project/main.ts","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}},"severity":1,"code":2304,"source":"deno-ts","message":"Cannot find name 'aaa'."}],"version":29}}

Is it possible for you to compare the log of working deno lsp and not working deno lsp?
Comment 11 witold 2025-09-30 11:38:48 UTC
In the version that works, all URIs are encoded like this: "file:///C:/Users/admin/test_project/test.ts" e.g.:

TRACE RS - deno_tower_lsp::codec:141 - -> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///C:/Users/admin/test_project/test.ts","diagnostics":[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}},"severity":1,"code":2304,"source":"deno-ts","message":"Cannot find name 'aaa'."}],"version":2}}

In the new version, which doesn't work, it changed to "file:///c%3A/Users/admin/test_project/test.ts" e.g.:

TRACE RS - deno_tower_lsp::codec:117 - -> {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///c%3A/Users/admin/test_project/test.ts","diagnostics" :[{"range":{"start":{"line":0,"character":0},"end":{"line":0,"character":3}},"severity":1,"code":2304,"source":"deno-ts","message":"Cannot find name 'aaa'."}],"version":2}}

And this stopped working since Deno version 2.2.7, which had this change: "fix(lsp): url_to_uri() encoding on windows" (https://github.com/denoland/deno/pull/28737).
Comment 12 witold 2025-09-30 11:50:30 UTC
After reviewing the LSP documentation (https://microsoft.github.io/language-server-protocol/specifications/specification-3-14/) and rfc3986, it appears this is a bug on Deno's end. However, VS Code and many others seem to handle this.
Comment 13 Waqar Ahmed 2025-10-02 14:12:29 UTC
What changed?
Comment 14 witold 2025-10-02 20:59:29 UTC
Sorry, maybe I don't understand the bug statuses. I thought it was closed, so I reopened it. If it is indeed closed, does that mean I should report it to Deno? 

In the meantime, I've confirmed that "c%3A" in URI is definitely the cause of the problem. I shared the folder as a network path (thus removing the "c%3A" from the URI) and everything works fine.
Comment 15 Waqar Ahmed 2025-10-03 07:43:54 UTC
What happens if you click the diagnostic item in the panel below? Does it take you to the right file and location?

Reading the spec, seems like both urls are valid but the spec says a server should stick to one consistent format.
Comment 16 witold 2025-10-03 09:04:44 UTC
Yes, clicking on an error in the Diagnostics tab moves the cursor to the appropriate file and location.
Comment 17 Waqar Ahmed 2025-10-03 18:22:58 UTC
Okay then that means this if doesn't work as expected:

https://invent.kde.org/utilities/kate/-/blob/master/apps/lib/diagnostics/diagnosticview.cpp?ref_type=heads#L1074
Comment 18 Waqar Ahmed 2025-10-03 18:23:57 UTC
Probably because one has small "c", while the other has capital "C" :/
Comment 19 Bug Janitor Service 2025-10-03 19:09:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/utilities/kate/-/merge_requests/1905
Comment 20 Christoph Cullmann 2025-10-04 18:55:58 UTC
Git commit 4873291136006a3203bec8e71e5ef5ee03521d53 by Christoph Cullmann, on behalf of Waqar Ahmed.
Committed on 04/10/2025 at 18:51.
Pushed by cullmann into branch 'master'.

Capitalize drive letters on windows

Capitalize the drive letter on windows. Our documents always have
capital letter because KateDocManager uses Utils::absoluteUrl() when
opening url KateDocManager::openUrl which reconstructs the url using
QFileInfo::absolouteFilePath() which returns a captialized drive letter
according to Qt docs. To match this behaviour, use
QFileInfo::absolouteFilePath() in Utils::normalizeUrl()

M  +11   -4    apps/lib/ktexteditor_utils.cpp

https://invent.kde.org/utilities/kate/-/commit/4873291136006a3203bec8e71e5ef5ee03521d53
Comment 21 Waqar Ahmed 2025-10-31 06:35:54 UTC
Git commit 12376ed540ac1ff525e3b777fbec6ed92574416c by Waqar Ahmed.
Committed on 31/10/2025 at 06:30.
Pushed by waqar into branch 'release/25.08'.

Capitalize drive letters on windows

Capitalize the drive letter on windows. Our documents always have
capital letter because KateDocManager uses Utils::absoluteUrl() when
opening url KateDocManager::openUrl which reconstructs the url using
QFileInfo::absolouteFilePath() which returns a captialized drive letter
according to Qt docs. To match this behaviour, use
QFileInfo::absolouteFilePath() in Utils::normalizeUrl()
(cherry picked from commit 4873291136006a3203bec8e71e5ef5ee03521d53)

M  +11   -4    apps/lib/ktexteditor_utils.cpp

https://invent.kde.org/utilities/kate/-/commit/12376ed540ac1ff525e3b777fbec6ed92574416c