Skip to content

Commit

Permalink
improvement: Retry code actions detection for Scala CLI
Browse files Browse the repository at this point in the history
I added it in a previous PR, but must have lost it during a rebase.
  • Loading branch information
tgodzik committed Oct 18, 2024
1 parent 0eddfd2 commit b1c3856
Showing 1 changed file with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ abstract class BaseCodeActionLspSuite(
if (renamePath.nonEmpty) input.replace("<<", "").replace(">>", "")
else expectedCode

def assertCodeAction(retry: Int): Future[List[CodeAction]] = {
server
.assertCodeAction(
path,
changeFile(input),
expectedActions,
kind,
filterAction = filterAction,
)
.recoverWith {
case _: Throwable if retry > 0 =>
Thread.sleep(2000)
assertCodeAction(retry - 1)
case _: Throwable if expectError =>
Future.successful(Nil)
}
}

test(name) {
assume(assumeFunc())
cleanWorkspace()
Expand All @@ -142,18 +160,7 @@ abstract class BaseCodeActionLspSuite(
path,
changeFile(input).replace("<<", "").replace(">>", ""),
)
codeActions <-
server
.assertCodeAction(
path,
changeFile(input),
expectedActions,
kind,
filterAction = filterAction,
)
.recover {
case _: Throwable if expectError => Nil
}
codeActions <- assertCodeAction(retryAction)
_ <- client.applyCodeAction(selectedActionIndex, codeActions, server)
_ <- server.didSave(newPath) { _ =>
if (newPath != path)
Expand Down

0 comments on commit b1c3856

Please sign in to comment.