Skip to content

Commit

Permalink
fix: don't include trailing whitespace in code action title
Browse files Browse the repository at this point in the history
The previous regex included trailing whitespace, including newline character, in the match. This meant the code action title (shown to users to trigger the action) had that trailing whitespace and newline.

This version of the regex uses a lookahead to check the `=` is followed by the end of the string or by whitespace and then the end of the string. (I.e. that the addition doesn't already have a sum.) The values in the lookahead aren't included in the match groups.

The trigger is only shown when users hover
  • Loading branch information
Ellen Potter authored and alcarney committed Sep 29, 2023
1 parent f18c51a commit fa00721
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/servers/code_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
)


ADDITION = re.compile(r"^\s*(\d+)\s*\+\s*(\d+)\s*=\s*$")
ADDITION = re.compile(r"^\s*(\d+)\s*\+\s*(\d+)\s*=(?=\s*$)")
server = LanguageServer("code-action-server", "v0.1")


Expand Down

0 comments on commit fa00721

Please sign in to comment.