Bugfix Tools::CodeView2::GutterView - do not redraw gutter if its not shown. jv
authorJan Vrany <jan.vrany@fit.cvut.cz>
Wed, 28 Aug 2013 12:52:38 +0100
branchjv
changeset 13465 1f1e8b6710c8
parent 13391 43eaa1c36082
child 13466 12798b6239c4
Bugfix Tools::CodeView2::GutterView - do not redraw gutter if its not shown. This actually fixes DNU when CodeView2 is used in diff view. Then the second gutter is not shown and #yOfTextViewLine: returns nil (bad) which leads to DNU.
Tools__CodeView2.st
--- a/Tools__CodeView2.st	Wed Aug 28 10:50:17 2013 +0100
+++ b/Tools__CodeView2.st	Wed Aug 28 12:52:38 2013 +0100
@@ -1413,11 +1413,7 @@
 
     "Created: / 06-07-2011 / 17:12:58 / jv"
     "Modified: / 06-10-2011 / 14:13:44 / cg"
-!
-
-
-
- !
+! !
 
 !CodeView2 methodsFor:'diff mode'!
 
@@ -2466,10 +2462,14 @@
 
     |visibleLineNr "{ Class: SmallInteger }"|
 
+    "/JV: BAD, BAD BAD - check senders, they are not prepared
+    "/    to get nil!!
     shown ifFalse:[^ nil].
     lineNr isNil ifTrue:[^ nil].
     visibleLineNr := lineNr - textView firstLineShown + 1.
     ^ textView yOfVisibleLine:visibleLineNr
+
+    "Modified (format): / 28-08-2013 / 12:49:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
 !CodeView2::GutterView methodsFor:'redrawing'!
@@ -2558,6 +2558,8 @@
     |lineString yTop yBaseline fontAscent fontDescent
      textW requiredW oldFont newFont oldColor newColor|
 
+    shown ifFalse:[ ^ self ]. "/ Do not bother if the view is not shown.
+
     lineString := self displayedString:line.
 
     textW := (lineString widthOn:self).
@@ -2568,15 +2570,15 @@
 
     newFont := self lineFontForLine:line.
     newFont isNil ifTrue:[
-	newFont := oldFont.
-	newColor := self lineColorForLine:line.
-	newColor ifNotNil:[ self paint:newColor ].
+        newFont := oldFont.
+        newColor := self lineColorForLine:line.
+        newColor ifNotNil:[ self paint:newColor ].
     ].
     newFont ~~ oldFont ifTrue:[
-	(newFont heightOn:device) > (textView font heightOn:device) ifTrue:[
-	    newFont := textView font.
-	].
-	self font:newFont
+        (newFont heightOn:device) > (textView font heightOn:device) ifTrue:[
+            newFont := textView font.
+        ].
+        self font:newFont
     ].
     fontAscent := textView font ascentOn:device.
     fontDescent := textView font descentOn:device.
@@ -2585,9 +2587,9 @@
     yBaseline := yTop + fontAscent.
 
     cleared ifFalse:[
-	self clearRectangleX:0 y:yBaseline - font ascent
-	    width: width - 2
-	    height: font ascent + font descent.
+        self clearRectangleX:0 y:yBaseline - font ascent
+            width: width - 2
+            height: font ascent + font descent.
     ].
 
     "/ cg: this should be done differently: services know about the
@@ -2595,31 +2597,32 @@
     "/ otherwise, some redraws become unusably slow (especially
     "/ with multiple fonts/colors/emphases)...
     drawServices ifTrue:[
-	"Let services draw annotations and other stuff"
-	codeView
-	    drawLine:line in: self
-	    atX: (self paddingLeft + self usedWidthForAcceptCancel) y:yBaseline width: widthAnnotations height: font height
-	    from:nil to:nil with:self paint and: self backgroundColor.
+        "Let services draw annotations and other stuff"
+        codeView
+            drawLine:line in: self
+            atX: (self paddingLeft + self usedWidthForAcceptCancel) y:yBaseline width: widthAnnotations height: font height
+            from:nil to:nil with:self paint and: self backgroundColor.
     ].
 
     self
-	displayString:lineString
-	x:(width - textW - 2 - self paddingRight - widthDiffInfo)
-	y:yBaseline.
+        displayString:lineString
+        x:(width - textW - 2 - self paddingRight - widthDiffInfo)
+        y:yBaseline.
 
     newFont
-	ifNotNil:[
-	    self font:oldFont.
-	    self paint:oldColor
-	]
-	ifNil:[
-	    newColor ifNotNil:[ self paint:oldColor ].
-	].
+        ifNotNil:[
+            self font:oldFont.
+            self paint:oldColor
+        ]
+        ifNil:[
+            newColor ifNotNil:[ self paint:oldColor ].
+        ].
     ^ requiredW.
 
     "Modified: / 14-12-2009 / 15:30:44 / Jindra <a>"
     "Created: / 17-06-2011 / 14:11:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Modified: / 18-07-2012 / 19:05:24 / cg"
+    "Modified: / 28-08-2013 / 12:45:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 redrawLinesFrom:start
@@ -3043,8 +3046,6 @@
     "Modified: / 02-05-2010 / 18:45:44 / Jakub <zelenja7@fel.cvut.cz>"
 !
 
-
-
 redrawLines
     "redraw diff lines"
 
@@ -3720,8 +3721,6 @@
 
 !CodeView2::TextView methodsFor:'scrolling'!
 
-
-
 basicScrollTo:anOrigin redraw:doRedraw
     super scrollTo:anOrigin redraw:doRedraw
 
@@ -3730,8 +3729,6 @@
     "Created: / 19-03-2012 / 17:01:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
-
-
 originChanged:delta
 
     super originChanged:delta.
@@ -3741,8 +3738,6 @@
     "Created: / 07-12-2009 / 21:50:49 / Jindra <a>"
 !
 
-
-
 scrollTo:anOrigin redraw:doRedraw
 
     codeView scrollTo:anOrigin redraw:doRedraw in: self.
@@ -3751,9 +3746,7 @@
     "Modified: / 06-04-2010 / 14:04:28 / Jakub <zelenja7@fel.cvut.cz>"
     "Modified: / 17-03-2012 / 10:06:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
     "Created: / 19-03-2012 / 17:05:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
-!
-
- !
+! !
 
 !CodeView2::TextView methodsFor:'undo & again'!