Skip to content

Commit

Permalink
json-extension: use an unique token for progress example
Browse files Browse the repository at this point in the history
The spec [1] and pygls implementation [2] needs the token to be unique.

By using an hardcoded token like this, the progress works only one time,
the second time there's an error that token is already registered.

1: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverInitiatedProgress

2: https://github.com/openlawlibrary/pygls//blob/ee17487e4f40f971e7ec6f7711fa8334c5b7b127/pygls/progress.py#L28
  • Loading branch information
perrinjerome committed Dec 14, 2022
1 parent de7a33e commit 2d2e776
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/json-extension/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ def semantic_tokens(ls: JsonLanguageServer, params: SemanticTokensParams):
@json_server.command(JsonLanguageServer.CMD_PROGRESS)
async def progress(ls: JsonLanguageServer, *args):
"""Create and start the progress on the client."""
token = 'token'
token = str(uuid.uuid4())
# Create
await ls.progress.create_async(token)
# Begin
Expand Down

0 comments on commit 2d2e776

Please sign in to comment.