Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix a problem where an incorrect region would be selected when the

block to be selected had no indentation.

Given

|def x():
    print()

print()

where | is point, er/mark-python-block should mark the region
delimited by brackets:

[def x():
    print()]
  • Loading branch information...
commit bbf9740b1e544fce9bb3c935ca5cfd8d016dff32 1 parent 357cd00
@fgeller fgeller authored
Showing with 4 additions and 11 deletions.
  1. +4 −11 python-el-fgallina-expansions.el
View
15 python-el-fgallina-expansions.el
@@ -98,17 +98,10 @@ than NEXT-INDENT-LEVEL."
;; Save indentation and look for the end of this block
(let ((block-indentation (current-indentation)))
(forward-line 1)
- (cond
- ;; When there is no indent, look for next start of a block,
- ;; without indent, or end of buffer.
- ((= 0 block-indentation)
- (while (and (re-search-forward er--python-block-start-regex (point-max) 'goto-end)
- (> (current-indentation) block-indentation))))
- ;; When indentation > 0, skip empty and lines with more indent
- (t
- (while (or (> (current-indentation) block-indentation)
- (looking-at (rx line-start (* whitespace) line-end)))
- (forward-line 1))))
+ (while (and (or (> (current-indentation) block-indentation)
+ (looking-at (rx line-start (* whitespace) line-end)))
+ (not (looking-at er--python-block-start-regex)))
+ (forward-line 1))
;; Find the end of the block by skipping comments backwards
(beginning-of-line)
(python-util-forward-comment -1)
Please sign in to comment.
Something went wrong with that request. Please try again.