Closed ellen364 closed 11 months ago
It looks like the regex now captures newline character at the end of the line which ending up in the code action title and failing the test. If you stripped the matched text that should fix it.
action = CodeAction(
- title=f"Evaluate '{match.group(0)}'",
+ title=f"Evaluate '{match.group(0).strip()}'",
kind=CodeActionKind.QuickFix,
edit=WorkspaceEdit(changes={document_uri: [text_edit]}),
)
Thanks again for opening this :)
Thanks for all your help getting started with pygls :)
I see what you mean about the newline character. Suspect the $
in the regex needs to be a non-capturing group, so that match.group(0)
doesn't include the newline. Will give it a try later.
I've pushed a commit that changes the ADDITION
regex to exclude trailing whitespace from the match group. All tests pass locally.
If you prefer the version that uses strip
, I'm happy to do that instead.
If you prefer the version that uses strip, I'm happy to do that instead.
No need! It was just the first solution that came to mind - I’d argue that yours is much more elegant anyway!
Description
In examples/code_actions, tighten the ADDITION regex so that the 'Evaluate' code action only appears if there's no sum. Previously, after using the action, the lightbulb remained visible in VSCode and would keep appending the sum to the line, resulting in things like
1 + 1 = 2! 2! 2!
Code review checklist (for code reviewer to complete)