diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Resources/Mode.xsd b/src/Libraries/ICSharpCode.TextEditor/Project/Resources/Mode.xsd index 42ae8f499a..5a01d8afdc 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Resources/Mode.xsd +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Resources/Mode.xsd @@ -92,9 +92,10 @@ - + - @@ -106,8 +107,9 @@ - + + diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Resources/VBNET-Mode.xshd b/src/Libraries/ICSharpCode.TextEditor/Project/Resources/VBNET-Mode.xshd index 4ec2b15569..74f4065591 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Resources/VBNET-Mode.xshd +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Resources/VBNET-Mode.xshd @@ -39,7 +39,7 @@ - REM + REM@C diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs index eba7cddee2..9be3d2f919 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/DefaultHighlightingStrategy.cs @@ -342,7 +342,7 @@ namespace ICSharpCode.TextEditor.Document // Check if the span state has changed, if so we must re-render the next line // This check may seem utterly complicated but I didn't want to introduce any function calls - // or alllocations here for perf reasons. + // or allocations here for perf reasons. if(currentLine.HighlightSpanStack != currentSpanStack) { if (currentLine.HighlightSpanStack == null) { processNextLine = false; @@ -618,7 +618,7 @@ namespace ICSharpCode.TextEditor.Document // check for SPAN BEGIN if (activeRuleSet != null) { foreach (Span span in activeRuleSet.Spans) { - if (currentLine.MatchExpr(span.Begin, i, document, activeRuleSet.IgnoreCase)) { + if ((!span.IsBeginSingleWord || currentLength == 0) && currentLine.MatchExpr(span.Begin, i, document, activeRuleSet.IgnoreCase)) { PushCurWord(document, ref markNext, words); string regex = currentLine.GetRegString(span.Begin, i, document); diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/Span.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/Span.cs index 5e5365d726..a235f686a8 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/Span.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/HighlightingStrategy/Span.cs @@ -31,6 +31,8 @@ namespace ICSharpCode.TextEditor.Document HighlightRuleSet ruleSet = null; bool noEscapeSequences = false; bool ignoreCase = false; + bool isBeginSingleWord = false; + bool isEndSingleWord = false; internal HighlightRuleSet RuleSet { get { @@ -56,6 +58,18 @@ namespace ICSharpCode.TextEditor.Document } } + public bool IsBeginSingleWord { + get { + return isBeginSingleWord; + } + } + + public bool IsEndSingleWord { + get { + return isEndSingleWord; + } + } + public HighlightColor Color { get { return color; @@ -128,9 +142,18 @@ namespace ICSharpCode.TextEditor.Document begin = span["Begin"].InnerText.ToCharArray(); beginColor = new HighlightColor(span["Begin"], color); + if (span["Begin"].HasAttribute("singleword")) { + this.isBeginSingleWord = Boolean.Parse(span["Begin"].GetAttribute("singleword")); + } + + if (span["End"] != null) { end = span["End"].InnerText.ToCharArray(); endColor = new HighlightColor(span["End"], color); + if (span["End"].HasAttribute("singleword")) { + this.isEndSingleWord = Boolean.Parse(span["End"].GetAttribute("singleword")); + } + } } } diff --git a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegment.cs b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegment.cs index 5b52f3292a..1b79fb0000 100644 --- a/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegment.cs +++ b/src/Libraries/ICSharpCode.TextEditor/Project/Src/Document/LineManager/LineSegment.cs @@ -168,6 +168,16 @@ namespace ICSharpCode.TextEditor.Document ++i; if (i < expr.Length) { switch (expr[i]) { + case 'C': // match whitespace or punctuation + if (index + j == this.Offset || index + j >= this.Offset + this.Length) { + // nothing (EOL or SOL) + } else { + char ch = document.GetCharAt(this.Offset + index + j); + if (!Char.IsWhiteSpace(ch) && !Char.IsPunctuation(ch)) { + return false; + } + } + break; case '!': // don't match the following expression { StringBuilder whatmatch = new StringBuilder();