[mono/monodevelop] a3e7bb7d: Fixed 'Bug 16126 - When searching in the whole solution, if there are
Mike Krüger (
[email protected]) <
[email protected]>
Tue, 12 Nov 2013 15:32:50 +0000
| Newsgroups |
gmane.comp.gnome.mono.patches |
| Message-ID |
<000001424cf1986f-e30688b1-eef6-44c7-96e0-d565b3fd36d5-000000@email.amazonses.com> |
Branch: refs/heads/master
Home: https://github.com/mono/monodevelop
Compare: https://github.com/mono/monodevelop/compare/459bb278e5ea...a3e7bb7dc14c
Commit: a3e7bb7dc14c13db3dc94e6d477a4df057419bef
Author: Mike Krüger <[email protected]> (mkrueger)
Date: 2013-11-12 15:31:44 GMT
URL: https://github.com/mono/monodevelop/commit/a3e7bb7dc14c13db3dc94e6d477a4df057419bef
Fixed 'Bug 16126 - When searching in the whole solution, if there are
many search matches (e.g. over 500-1000) an error is displayed'.
Changed paths:
M main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs
Modified: main/src/core/Mono.Texteditor/Mono.TextEditor/TextEditorData.cs
===================================================================
@@ -278,16 +278,55 @@ void HandleTextReplaced (object sender, DocumentChangeEventArgs e)
ColorScheme colorStyle;
public ColorScheme ColorStyle {
get {
- return colorStyle ?? Mono.TextEditor.Highlighting.SyntaxModeService.DefaultColorStyle;
+ return colorStyle ?? SyntaxModeService.DefaultColorStyle;
}
set {
colorStyle = value;
}
}
+
+ string ConvertToPangoMarkup (string str, bool replaceTabs = true)
+ {
+ if (str == null)
+ throw new ArgumentNullException ("str");
+ var result = new StringBuilder ();
+ foreach (char ch in str) {
+ switch (ch) {
+ case '&':
+ result.Append ("&");
+ break;
+ case '<':
+ result.Append ("<");
+ break;
+ case '>':
+ result.Append (">");
+ break;
+ case '\t':
+ if (replaceTabs) {
+ result.Append (new string (' ', options.TabSize));
+ } else {
+ result.Append ('\t');
+ }
+ break;
+ default:
+ result.Append (ch);
+ break;
+ }
+ }
+ return result.ToString ();
+ }
public string GetMarkup (int offset, int length, bool removeIndent, bool useColors = true, bool replaceTabs = true)
{
ISyntaxMode mode = Document.SyntaxMode;
+ var style = ColorStyle;
+
+ if (style == null) {
+ var str = Document.GetTextAt (offset, length);
+ if (removeIndent)
+ str = str.TrimStart (' ', '\t');
+ return ConvertToPangoMarkup (str, replaceTabs);
+ }
int indentLength = SyntaxMode.GetIndentLength (Document, offset, length, false);
int curOffset = offset;
@@ -298,8 +337,8 @@ public string GetMarkup (int offset, int length, bool removeIndent, bool useColo
int toOffset = System.Math.Min (line.Offset + line.Length, offset + length);
var styleStack = new Stack<ChunkStyle> ();
- foreach (var chunk in mode.GetChunks (ColorStyle, line, curOffset, toOffset - curOffset)) {
- var chunkStyle = ColorStyle.GetChunkStyle (chunk);
+ foreach (var chunk in mode.GetChunks (style, line, curOffset, toOffset - curOffset)) {
+ var chunkStyle = style.GetChunkStyle (chunk);
bool setBold = (styleStack.Count > 0 && styleStack.Peek ().FontWeight != chunkStyle.FontWeight) ||
chunkStyle.FontWeight != FontWeight.Normal;
bool setItalic = (styleStack.Count > 0 && styleStack.Peek ().FontStyle != chunkStyle.FontStyle) ||
@@ -327,31 +366,7 @@ public string GetMarkup (int offset, int length, bool removeIndent, bool useColo
result.Append (">");
styleStack.Push (chunkStyle);
}
-
- for (int i = 0; i < chunk.Length && chunk.Offset + i < Document.TextLength; i++) {
- char ch = Document.GetCharAt (chunk.Offset + i);
- switch (ch) {
- case '&':
- result.Append ("&");
- break;
- case '<':
- result.Append ("<");
- break;
- case '>':
- result.Append (">");
- break;
- case '\t':
- if (replaceTabs) {
- result.Append (new string (' ', options.TabSize));
- } else {
- result.Append ('\t');
- }
- break;
- default:
- result.Append (ch);
- break;
- }
- }
+ result.Append (ConvertToPangoMarkup (Document.GetTextBetween (chunk.Offset, System.Math.Min (chunk.EndOffset, Document.TextLength)), replaceTabs));
}
while (styleStack.Count > 0) {
result.Append ("</span>");
@@ -552,13 +567,13 @@ public bool CanEdit (int line)
return !document.ReadOnly;
}
- public int FindNextWordOffset (int offset)
+ public int FindNextWordOffset (int offset)
{
return options.WordFindStrategy.FindNextWordOffset (Document, offset);
}
-
- public int FindPrevWordOffset (int offset)
- {
+
+ public int FindPrevWordOffset (int offset)
+ {
return options.WordFindStrategy.FindPrevWordOffset (Document, offset);
}
@@ -809,15 +824,15 @@ protected virtual void OnSelectionChanging (EventArgs e)
public IEnumerable<DocumentLine> SelectedLines {
get {
if (!IsSomethingSelected)
- return document.GetLinesBetween (caret.Line, caret.Line);
- var selection = MainSelection;
+ return document.GetLinesBetween (caret.Line, caret.Line);
+ var selection = MainSelection;
int startLineNr = selection.MinLine;
int endLineNr = selection.MaxLine;
bool skipEndLine = selection.Anchor < selection.Lead ? selection.Lead.Column == DocumentLocation.MinColumn : selection.Anchor.Column == DocumentLocation.MinColumn;
- if (skipEndLine)
- endLineNr--;
- return document.GetLinesBetween (startLineNr, endLineNr);
+ if (skipEndLine)
+ endLineNr--;
+ return document.GetLinesBetween (startLineNr, endLineNr);
}
}
@@ -981,9 +996,9 @@ protected virtual void OnSearchChanged (EventArgs args)
OnSearchChanged (EventArgs.Empty);
};
}
- return currentSearchRequest;
- }
- }
+ return currentSearchRequest;
+ }
+ }
public bool IsMatchAt (int offset)
{
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches