'use babel'

const COLOR_EXTRACTION_REGEXP = /rgb\(\d+, \d+, \d+\)|\#[0-9a-f]{3,6}/

export function isColor(textEditor, bufferPosition) {
  const lineText = textEditor.getTextInRange([[bufferPosition.row, 0], [bufferPosition.row, Infinity]])
  const matches = COLOR_EXTRACTION_REGEXP.exec(lineText)
  if (matches === null) {
    return false
  }
  const offsetStart = matches.index
  const offsetEnd = offsetStart + matches[0].length
  return bufferPosition.column >= offsetStart && offsetEnd >= bufferPosition.column
}

@@ -53,20 +53,57 @@
 d+, 
+?
 %5Cd+, 
+?
 %5Cd+%5C)%7C
-%5C
+rgba%5C(%5Cd+, ?%5Cd+, ?%5Cd+, ?%5Cd?%5C.?%5Cd+%5C)%7C
 #%5B0-

Add rgba support to regex