From bc154f889692dc35eba84adca43e9ccdf0302132 Mon Sep 17 00:00:00 2001 From: Chris Kim Date: Wed, 9 May 2018 02:25:59 -0400 Subject: [PATCH] Proper fix for case where cursor is between last character and quote --- select_quotes.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/select_quotes.py b/select_quotes.py index 6483c86..e36bf31 100644 --- a/select_quotes.py +++ b/select_quotes.py @@ -37,17 +37,18 @@ def getStringRegion(self, region, around=False): if self.view.score_selector(pos, "string.quoted") <= 0: return None - # Turn on 'round' implicitly if... - # The start of the selection is a quote - if self.view.score_selector(region.a, "punctuation.definition.string") > 0: - around = True - # The end of the selection is a quote - if self.view.score_selector(region.b, "punctuation.definition.string") > 0: - around = False - # The selected region is abutted by quotes on either side - if (self.view.score_selector(region.a - 1, "punctuation.definition.string") > 0 and - self.view.score_selector(region.b + 1, "punctuation.definition.string") > 0): - around = True + if region.a != region.b: + # Turn on 'round' implicitly if... + # The start of the selection is a quote + if self.view.score_selector(region.a, "punctuation.definition.string") > 0: + around = True + # The end of the selection is a quote + if self.view.score_selector(region.b, "punctuation.definition.string") > 0: + around = True + # The selected region is abutted by quotes on either side + if (self.view.score_selector(region.a - 1, "punctuation.definition.string") > 0 and + self.view.score_selector(region.b + 1, "punctuation.definition.string") > 0): + around = True # Predicates for if we should continue expanding the selection foreward/back if around: