`withProgress Cancellable` doesn't seem to work?

オープン
#538 コメント 12 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
haskell
領域
devtools

調査の方向性

まず、lsp ソースにある withProgress の実装と、"window/workDoneProgress/cancel" 用の組み込みハンドラーを読みます。提供された onExecuteCommand の例で問題を再現し、その後、非同期処理を待機するとキャンセル処理が妨げられるかどうかを追跡します。キャンセルによってシミュレートされた処理が停止し、ハンドラーがないというエラーが発生しなければ完了です。

索引モデルが issue の本文から書いたものです。

説明

v3

Hello,
I've just started using this package recently, so possibly I am using it incorrectly, or misunderstand something. The issue is that I can't seem to get withProgress to work correctly when an action is cancelled. To test it, I've made a server function like this:

onExecuteCommand :: LSP.ExecuteCommandParams -> M () -> M ()
onExecuteCommand _ps k =
  Srv.withProgress "PROG" Srv.Cancellable (go 0)
  where
  go n advance =
    if n < 100
      then do
        liftIO (threadDelay (1 * 10^(6::Int)))
        _ <- advance (Srv.ProgressAmount (Just n)
                     (Just (Text.pack ("THING: " ++ show n))))
        go (n+5) advance
      else k
    `catch` \(_ :: Srv.ProgressCancelledException) -> do
      lspShow Info "Cancelled"

Basically the idea is that we sleep for a second a bunch of times to simulate work. This works great as long as you don't cancel the action. If the action is cancelled, the work seems to continue executing, and when it is finished I get this error:

LSP: no handler for: "window/workDoneProgress/cancel"

Looking at lsp's source code, it looks like there is a built-in handler for this, which makes sense. However, this handler never seems to fire.

I wonder if the problem is that in the implementation of withProgress, we fork off the work with async, but then we wait for it straight away, so we are blocked and can't handle the cancel message from the client?

Thoughts?

主要言語
Haskell
スター
426
フォーク
107
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

haskell/lsp のほかの issue

haskell/lsp の issue をすべて見る

似ている issue

Haskell の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。