Tools__CodeNavigationService.st
branchjv
changeset 13618 aa7dd2f6dc46
parent 13613 066908b0c801
child 15566 184cea584be5
--- a/Tools__CodeNavigationService.st	Fri Sep 27 23:48:07 2013 +0100
+++ b/Tools__CodeNavigationService.st	Wed Oct 02 02:48:56 2013 +0100
@@ -67,6 +67,7 @@
 "
 ! !
 
+
 !CodeNavigationService class methodsFor:'accessing'!
 
 label
@@ -542,14 +543,20 @@
         index > syntaxElements size ifTrue:[^nil].
         element := syntaxElements at:index ifAbsent:nil.
         element notNil ifTrue:[
-            (characterPosition between: element start - 1 and: element stop) ifTrue:[^element].
+            (characterPosition between: element start and: element stop) ifTrue:[^element].
         ].
+        index + 1 > syntaxElements size ifTrue:[^nil].
+        element := syntaxElements at:index + 1 ifAbsent:nil.
+        element notNil ifTrue:[
+            (characterPosition between: element start and: element stop) ifTrue:[^element].
+        ].
+
     ].
     ^nil
 
     "Created: / 25-06-2010 / 14:40:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 21-08-2011 / 11:03:29 / cg"
-    "Modified: / 16-09-2011 / 17:04:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 02-10-2013 / 01:22:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 elementAtX:x y:y 
@@ -690,28 +697,13 @@
 !
 
 highlightElementAtLine:line col:col 
-    |characterPosition syntaxElements index elementOrNil|
+    |elementOrNil|
 
-    characterPosition := textView characterPositionOfLine:line col:col.
-    syntaxElements := codeView syntaxElements.
-    syntaxElements isEmptyOrNil ifTrue:[
-        elementOrNil := nil.
-    ] ifFalse:[
-        index := syntaxElements indexForInserting:characterPosition.
-        index > syntaxElements size ifTrue:[
-            elementOrNil := nil.
-        ] ifFalse:[
-            elementOrNil := syntaxElements at:index.
-            (characterPosition between: elementOrNil start and: elementOrNil stop) ifFalse:[
-                elementOrNil := nil
-            ].
-        ]
-    ].
-
+    elementOrNil := self elementAtLine: line col: col.
     self highlightElement:elementOrNil
 
     "Created: / 14-02-2010 / 16:17:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-    "Modified: / 01-08-2010 / 08:50:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 02-10-2013 / 01:29:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 highlightElementAtX:x y:y