Skip to content
Browse files

Insert color if there is no color to replace

Had some trouble when adding color to:

asd {
  background-color:[INSERT HERE];
}

Where the : would have been replaced with the color.
  • Loading branch information...
1 parent 82b8d0e commit d9f9227fda6623f80436d59da4345a1e68dbb3fe @hnesland committed Sep 21, 2011
Showing with 7 additions and 5 deletions.
  1. +7 −5 ColorPick.py
View
12 ColorPick.py
@@ -20,11 +20,13 @@ def run(self, edit):
args.append(selected)
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
color = proc.communicate()[0]
-
+
if color:
# replace all regions with color
for region in sel:
- word = view.word(region)
- if view.substr(word.a - 1) == '#':
- word = sublime.Region(word.a - 1, word.b)
- self.view.replace(edit, word, '#' + color)
+ word = view.word(region)
+ if view.substr(word.a - 1) == '#':
+ word = sublime.Region(word.a - 1, word.b)
+ self.view.replace(edit, word, '#' + color)
+ else:
+ self.view.insert(edit, sel[0].begin(), '#' + color)

0 comments on commit d9f9227

Please sign in to comment.
Something went wrong with that request. Please try again.