Skip to content

Commit cb21b85

Browse files
Fix lambda at the end of a word messing up python spacing
1 parent 8a88a93 commit cb21b85

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

electric-operator.el

+1-1
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,7 @@ Also handles C++ lambda capture by reference."
863863
(defun electric-operator-python-mode-in-lambda-args? ()
864864
"Are we inside the arguments statement of a lambda?"
865865
;; \\(\\s-\\|^\\) instead of just \\b because otherwise foo_lambda matches
866-
(electric-operator-looking-back-locally "\\(\\s-\\|^\\)lambda[^:]*"))
866+
(electric-operator-looking-back-locally "\\(\\s-\\|^\\)lambda\\s-[^:]*"))
867867

868868
(defun electric-operator-python-mode-: ()
869869
"Handle python dict assignment"

features/python-mode.feature

+8
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,18 @@ Feature: Python mode basics
164164
When I type "foolambdabar=1"
165165
Then I should see "foolambdabar = 1"
166166

167+
Scenario: Lambda at the start of another word doesn't affect spacing
168+
When I type "lambdabar=1"
169+
Then I should see "lambdabar = 1"
170+
167171
Scenario: Lambda inside another word with _ doesn't affect spacing
168172
When I type "foo_lambdabar=1"
169173
Then I should see "foo_lambdabar = 1"
170174

175+
Scenario: Zero argument lambda
176+
When I type "lambda: x, y=1"
177+
Then I should see "lambda: x, y = 1"
178+
171179
# Slice operator
172180
Scenario: Don't space : inside slices
173181
When I type "a[1:2]"

0 commit comments

Comments
 (0)