diff --git a/Language/Haskell/HsColour/Anchors.hs b/Language/Haskell/HsColour/Anchors.hs
--- a/Language/Haskell/HsColour/Anchors.hs
+++ b/Language/Haskell/HsColour/Anchors.hs
@@ -148,13 +148,21 @@
 -- the anchor name for an instance is just the entire instance head, minus
 -- any extra context clause
 getInstance = Just . unwords . ("instance":) . words . concat . map snd
-              . trimContext . takeWhile (/=(Keyword,"where"))
+              . trimContext . takeWhile (not . terminator)
   where
     trimContext ts = if (Keyglyph,"=>") `elem` ts
                      ||  (Keyglyph,"⇒") `elem` ts
                      then tail . dropWhile (`notElem`[(Keyglyph,"=>")
                                                      ,(Keyglyph,"⇒")]) $ ts
                      else ts
+    terminator (Keyword, _)   = True
+    terminator (Comment, _)   = True
+    terminator (Cpp,     _)   = True
+    terminator (Keyglyph,"|") = True
+    terminator (Layout,  ";") = True
+    terminator (Layout,  "{") = True
+    terminator (Layout,  "}") = True
+    terminator _              = False
 
 -- simple implementation of a string lookup table.
 -- replace this with something more sophisticated if needed.
diff --git a/hscolour.cabal b/hscolour.cabal
--- a/hscolour.cabal
+++ b/hscolour.cabal
@@ -1,5 +1,5 @@
 Name: hscolour
-Version: 1.22
+Version: 1.23
 Copyright: 2003-2015 Malcolm Wallace; 2006 Bjorn Bringert
 Maintainer: Malcolm Wallace
 Author: Malcolm Wallace
