-
Notifications
You must be signed in to change notification settings - Fork 472
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from ltrzesniewski/keywords-order
Prioritize longer keywords also when they're not alphanumeric
- Loading branch information
Showing
2 changed files
with
41 additions
and
2 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
ICSharpCode.AvalonEdit.Tests/Highlighting/XmlHighlightingDefinitionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System.Linq; | ||
|
||
using ICSharpCode.AvalonEdit.Document; | ||
using ICSharpCode.AvalonEdit.Highlighting; | ||
using ICSharpCode.AvalonEdit.Highlighting.Xshd; | ||
|
||
using NUnit.Framework; | ||
|
||
namespace ICSharpCode.AvalonEdit.Tests.Highlighting | ||
{ | ||
[TestFixture] | ||
public class XmlHighlightingDefinitionTests | ||
{ | ||
[Test] | ||
public void LongerKeywordsArePreferred() | ||
{ | ||
var color = new XshdColor { Name = "Result" }; | ||
var syntaxDefinition = new XshdSyntaxDefinition { | ||
Elements = { | ||
color, | ||
new XshdRuleSet { | ||
Elements = { new XshdKeywords { | ||
ColorReference = new XshdReference<XshdColor>(null, color.Name), | ||
Words = { "foo", "foo.bar." } | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
var document = new TextDocument("This is a foo.bar. keyword"); | ||
var highlighter = new DocumentHighlighter(document, new XmlHighlightingDefinition(syntaxDefinition, HighlightingManager.Instance)); | ||
var result = highlighter.HighlightLine(1); | ||
|
||
var highlightedText = document.GetText(result.Sections.Single()); | ||
Assert.That(highlightedText, Is.EqualTo("foo.bar.")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters