Skip to content

Commit 61524d5

Browse files
committed
Fixed the bug: Pull requests(DebugST#1)
1 parent 9bb5b92 commit 61524d5

File tree

1 file changed

+15
-18
lines changed

1 file changed

+15
-18
lines changed

ST.Library.UI.STTextBox/Implementation/StyleMonitor/SelectionStyleMonitor.cs

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,26 +44,23 @@ public void OnSelectionChanged(TextManager textManager, int nStart, int nLen) {
4444
});
4545

4646
// https://github.com/DebugST/STTextBox/pull/1
47-
//if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey)) {
48-
// strKey = "\\" + strKey;
49-
//}
47+
// if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey)) {
48+
// strKey = "\\" + strKey;
49+
// }
5050
strKey = m_reg_reg.Replace(strKey, @"\$1");
51-
if (!string.IsNullOrEmpty(strKey)) {
52-
string strText = textManager.GetText();
53-
List<TextStyleRange> lst = new List<TextStyleRange>();
54-
if ("* . ? + $ ^ [ ] ( ) { } | \\ /".Split(' ').Contains(strKey))
55-
{
56-
strKey = "\\" + strKey;
57-
}
58-
foreach (Match m in Regex.Matches(strText, "\\b" + strKey + "\\b")) { // * . ? + $ ^ [ ] ( ) { } | \ /
59-
lst.Add(new TextStyleRange() {
60-
Index = m.Index,
61-
Length = m.Length,
62-
Style = this.Style
63-
});
64-
}
65-
m_lst = TextStyleMonitor.FillDefaultStyle(lst, strText.Length, TextStyle.Empty);
51+
if (string.IsNullOrEmpty(strKey)) {
52+
return;
53+
}
54+
string strText = textManager.GetText();
55+
List<TextStyleRange> lst = new List<TextStyleRange>();
56+
foreach (Match m in Regex.Matches(strText, "\\b" + strKey + "\\b")) {
57+
lst.Add(new TextStyleRange() {
58+
Index = m.Index,
59+
Length = m.Length,
60+
Style = this.Style
61+
});
6662
}
63+
m_lst = TextStyleMonitor.FillDefaultStyle(lst, strText.Length, TextStyle.Empty);
6764
}
6865

6966
public void OnTextChanged(TextManager textManager, List<TextHistoryRecord> thrs) {

0 commit comments

Comments
 (0)