Skip to content

Commit a8d1d22

Browse files
committed
Allow create work-done-progress without percentages, for report only.
1 parent 5f10ea7 commit a8d1d22

File tree

3 files changed

+26
-19
lines changed

3 files changed

+26
-19
lines changed

.clj-kondo/config.edn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{:linters {:clojure-lsp/unused-public-var {:exclude [lsp4clj.coercer]}}}

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44

5+
- Allow create work-done-progress without percentages, for report only.
6+
57
## v1.7.4
68

79
- Deprecate `lsp4clj.socket-server` and document preferred alternative in the README.

src/lsp4clj/lsp/requests.clj

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,26 @@
2525
2626
https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workDoneProgress
2727
"
28-
[percentage message progress-token]
29-
(when progress-token
30-
(let [percentage (int (clamp percentage 0 100))
31-
progress (case percentage
32-
;; TODO: this is a bit restricting. Technically the 'begin'
33-
;; message can start at a higher `percentage`, and it can
34-
;; have a `message`. To work around this, it's possible to
35-
;; publish a 'begin' immediately followed by a 'progress'
36-
;; with the desired percentage and message.
37-
0 {:kind :begin
38-
:title message
39-
:percentage 0}
40-
100 {:kind :end
41-
:message message}
42-
{:kind :report
43-
:message message
44-
:percentage percentage})]
45-
{:token progress-token
46-
:value progress})))
28+
([message progress-token]
29+
(work-done-progress nil message progress-token))
30+
([percentage message progress-token]
31+
(when progress-token
32+
(let [percentage (when percentage (int (clamp percentage 0 100)))
33+
progress (cond
34+
;; TODO: this is a bit restricting. Technically the 'begin'
35+
;; message can start at a higher `percentage`, and it can
36+
;; have a `message`. To work around this, it's possible to
37+
;; publish a 'begin' immediately followed by a 'progress'
38+
;; with the desired percentage and message.
39+
(= 0 percentage) {:kind :begin
40+
:title message
41+
:percentage 0}
42+
(= 100 percentage) {:kind :end
43+
:message message}
44+
:else
45+
(cond->
46+
{:kind :report
47+
:message message}
48+
percentage (assoc :percentage percentage)))]
49+
{:token progress-token
50+
:value progress}))))

0 commit comments

Comments
 (0)