Skip to content

Commit

Permalink
Fix lambda at the end of a word messing up python spacing
Browse files Browse the repository at this point in the history
  • Loading branch information
davidshepherd7 committed Aug 28, 2023
1 parent 8a88a93 commit cb21b85
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion electric-operator.el
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ Also handles C++ lambda capture by reference."
(defun electric-operator-python-mode-in-lambda-args? ()
"Are we inside the arguments statement of a lambda?"
;; \\(\\s-\\|^\\) instead of just \\b because otherwise foo_lambda matches
(electric-operator-looking-back-locally "\\(\\s-\\|^\\)lambda[^:]*"))
(electric-operator-looking-back-locally "\\(\\s-\\|^\\)lambda\\s-[^:]*"))

(defun electric-operator-python-mode-: ()
"Handle python dict assignment"
Expand Down
8 changes: 8 additions & 0 deletions features/python-mode.feature
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,18 @@ Feature: Python mode basics
When I type "foolambdabar=1"
Then I should see "foolambdabar = 1"

Scenario: Lambda at the start of another word doesn't affect spacing
When I type "lambdabar=1"
Then I should see "lambdabar = 1"

Scenario: Lambda inside another word with _ doesn't affect spacing
When I type "foo_lambdabar=1"
Then I should see "foo_lambdabar = 1"

Scenario: Zero argument lambda
When I type "lambda: x, y=1"
Then I should see "lambda: x, y = 1"

# Slice operator
Scenario: Don't space : inside slices
When I type "a[1:2]"
Expand Down

0 comments on commit cb21b85

Please sign in to comment.