recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
authorwenzelm
Mon, 03 Mar 2014 12:24:14 +0100
changeset 55883 6f50d445f0e3
parent 55882 912c9aa8de32
child 55884 f2c0eaedd579
recovered position hyperlinks from 65c9968286d5 (NB: "def" position vs. regular one);
src/Tools/jEdit/src/rendering.scala
--- a/src/Tools/jEdit/src/rendering.scala	Mon Mar 03 12:18:59 2014 +0100
+++ b/src/Tools/jEdit/src/rendering.scala	Mon Mar 03 12:24:14 2014 +0100
@@ -327,16 +327,6 @@
 
   /* hyperlinks */
 
-  private def hyperlink_file(props: Properties.T): Option[PIDE.editor.Hyperlink] =
-    props match {
-      case Position.Def_Line_File(line, name) =>
-        val offset = Position.Def_Offset.unapply(props) getOrElse 0
-        PIDE.editor.hyperlink_source_file(name, line, offset)
-      case Position.Def_Id_Offset(id, offset) =>
-        PIDE.editor.hyperlink_command_id(snapshot, id, offset)
-      case _ => None
-    }
-
   def hyperlink(range: Text.Range): Option[Text.Info[PIDE.editor.Hyperlink]] =
   {
     snapshot.cumulate[Vector[Text.Info[PIDE.editor.Hyperlink]]](
@@ -357,12 +347,28 @@
             { case (Markup.KIND, Markup.ML_OPEN) => true
               case (Markup.KIND, Markup.ML_STRUCTURE) => true
               case _ => false }) =>
-            hyperlink_file(props).map(link =>
-              (links :+ Text.Info(snapshot.convert(info_range), link)))
+            val opt_link =
+              props match {
+                case Position.Def_Line_File(line, name) =>
+                  val offset = Position.Def_Offset.unapply(props) getOrElse 0
+                  PIDE.editor.hyperlink_source_file(name, line, offset)
+                case Position.Def_Id_Offset(id, offset) =>
+                  PIDE.editor.hyperlink_command_id(snapshot, id, offset)
+                case _ => None
+              }
+            opt_link.map(link => (links :+ Text.Info(snapshot.convert(info_range), link)))
 
           case (links, Text.Info(info_range, XML.Elem(Markup(Markup.POSITION, props), _))) =>
-            hyperlink_file(props).map(link =>
-              (links :+ Text.Info(snapshot.convert(info_range), link)))
+            val opt_link =
+              props match {
+                case Position.Line_File(line, name) =>
+                  val offset = Position.Offset.unapply(props) getOrElse 0
+                  PIDE.editor.hyperlink_source_file(name, line, offset)
+                case Position.Id_Offset(id, offset) =>
+                  PIDE.editor.hyperlink_command_id(snapshot, id, offset)
+                case _ => None
+              }
+            opt_link.map(link => (links :+ Text.Info(snapshot.convert(info_range), link)))
 
           case _ => None
         }) match { case Text.Info(_, _ :+ info) :: _ => Some(info) case _ => None }