Browse Source

Fixed SD2-1504: Tooltip not shown when code folded

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3756 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 17 years ago
parent
commit
efc40af0ff
  1. 6
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs
  2. 43
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs
  3. 6
      src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs

6
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextAreaMouseHandler.cs

@ -362,7 +362,11 @@ namespace ICSharpCode.TextEditor
clickedOnSelectedText = true; clickedOnSelectedText = true;
} }
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.TextView.Document, new TextLocation(marker.StartColumn, marker.StartLine), new TextLocation(marker.EndColumn, marker.EndLine))); TextLocation startLocation = new TextLocation(marker.StartColumn, marker.StartLine);
TextLocation endLocation = new TextLocation(marker.EndColumn, marker.EndLine);
textArea.SelectionManager.SetSelection(new DefaultSelection(textArea.TextView.Document, startLocation, endLocation));
textArea.Caret.Position = startLocation;
textArea.SetDesiredColumn();
textArea.Focus(); textArea.Focus();
return; return;
} }

43
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs

@ -774,26 +774,35 @@ namespace ICSharpCode.TextEditor
int result; int result;
using (Graphics g = textArea.CreateGraphics()) { using (Graphics g = textArea.CreateGraphics()) {
do { // call GetLogicalColumnInternal to skip over text,
// then skip over fold markers
// and repeat as necessary.
// The loop terminates once the correct logical column is reached in
// GetLogicalColumnInternal or inside a fold marker.
while (true) {
LineSegment line = Document.GetLineSegment(lineNumber); LineSegment line = Document.GetLineSegment(lineNumber);
FoldMarker nextFolding = FindNextFoldedFoldingOnLineAfterColumn(lineNumber, start-1); FoldMarker nextFolding = FindNextFoldedFoldingOnLineAfterColumn(lineNumber, start-1);
int end = nextFolding != null ? nextFolding.StartColumn : int.MaxValue; int end = nextFolding != null ? nextFolding.StartColumn : int.MaxValue;
result = GetLogicalColumnInternal(g, line, start, end, ref posX, visualPosX); result = GetLogicalColumnInternal(g, line, start, end, ref posX, visualPosX);
if (result < 0) {
// reached fold marker // break when GetLogicalColumnInternal found the result column
lineNumber = nextFolding.EndLine; if (result < end)
start = nextFolding.EndColumn; break;
int newPosX = posX + 1 + MeasureStringWidth(g, nextFolding.FoldText, TextEditorProperties.FontContainer.RegularFont);
if (newPosX >= visualPosX) { // reached fold marker
inFoldMarker = nextFolding; lineNumber = nextFolding.EndLine;
if (IsNearerToAThanB(visualPosX, posX, newPosX)) start = nextFolding.EndColumn;
return new TextLocation(nextFolding.StartColumn, nextFolding.StartLine); int newPosX = posX + 1 + MeasureStringWidth(g, nextFolding.FoldText, TextEditorProperties.FontContainer.RegularFont);
else if (newPosX >= visualPosX) {
return new TextLocation(nextFolding.EndColumn, nextFolding.EndLine); inFoldMarker = nextFolding;
} if (IsNearerToAThanB(visualPosX, posX, newPosX))
posX = newPosX; return new TextLocation(nextFolding.StartColumn, nextFolding.StartLine);
else
return new TextLocation(nextFolding.EndColumn, nextFolding.EndLine);
} }
} while (result < 0); posX = newPosX;
}
} }
return new TextLocation(result, lineNumber); return new TextLocation(result, lineNumber);
} }
@ -801,7 +810,7 @@ namespace ICSharpCode.TextEditor
int GetLogicalColumnInternal(Graphics g, LineSegment line, int start, int end, ref int drawingPos, int targetVisualPosX) int GetLogicalColumnInternal(Graphics g, LineSegment line, int start, int end, ref int drawingPos, int targetVisualPosX)
{ {
if (start == end) if (start == end)
return -1; return end;
Debug.Assert(start < end); Debug.Assert(start < end);
Debug.Assert(drawingPos < targetVisualPosX); Debug.Assert(drawingPos < targetVisualPosX);
@ -824,7 +833,7 @@ namespace ICSharpCode.TextEditor
for (int i = 0; i < words.Count; i++) { for (int i = 0; i < words.Count; i++) {
TextWord word = words[i]; TextWord word = words[i];
if (wordOffset >= end) { if (wordOffset >= end) {
return -1; return wordOffset;
} }
if (wordOffset + word.Length >= start) { if (wordOffset + word.Length >= start) {
int newDrawingPos; int newDrawingPos;

6
src/Libraries/NRefactory/Test/Output/CSharp/CSharpOutputTest.cs

@ -89,6 +89,12 @@ namespace ICSharpCode.NRefactory.Tests.PrettyPrinter
TestTypeMember("void Method() { }"); TestTypeMember("void Method() { }");
} }
[Test]
public void StaticMethod()
{
TestTypeMember("static void Method() { }");
}
[Test] [Test]
public void PartialModifier() public void PartialModifier()
{ {

Loading…
Cancel
Save