Permalink
Browse files

Only proceed to next line when not looking at the start of a block and

the current indent is deeper than the target block's indent. Fixes
issue with selecting a nested block with trailing statements.

Adds test for marking a nested block with trailing statements in the
outer block.
  • Loading branch information...
1 parent b400719 commit e643a268d8988556d3991c18004d22a580aa5ec2 @fgeller fgeller committed Jul 24, 2012
Showing with 34 additions and 1 deletion.
  1. +31 −0 features/fgallina-python-el-expansions.feature
  2. +3 −1 python-el-fgallina-expansions.el
View
31 features/fgallina-python-el-expansions.feature
@@ -197,3 +197,34 @@ Feature: fgallinas python.el expansions
else:
print('Booyah.')
"""
+
+ Scenario: Mark nested Python block with subsequent statements in outer block
+ Given I turn on python-mode
+ And there is no region selected
+ When I insert:
+ """
+ def outer_foo():
+
+ def inner_foo():
+ return 23
+
+ return inner_foo()
+
+ """
+ And I go to point "23"
+ And I press "C-@"
+ Then the region should be:
+ """
+ def
+ """
+ And I press "C-@"
+ Then the region should be:
+ """
+ def inner_foo():
+ """
+ And I press "C-@"
+ Then the region should be:
+ """
+ def inner_foo():
+ return 23
+ """
View
4 python-el-fgallina-expansions.el
@@ -123,7 +123,9 @@ than NEXT-INDENT-LEVEL."
;; Looking at an empty line
(looking-at (rx line-start (* whitespace) line-end))
;; We're not looking at the start of a Python block
- (not (looking-at er--python-block-start-regex))))
+ ;; and the indent is deeper than the block's indent
+ (and (not (looking-at er--python-block-start-regex))
+ (> (current-indentation) block-indentation))))
(forward-line 1)
(back-to-indentation))
;; Find the end of the block by skipping comments backwards

0 comments on commit e643a26

Please sign in to comment.