@@ -47,6 +47,9 @@ class LogView:
47
47
"none" : sublime .DRAW_NO_FILL | sublime .DRAW_NO_OUTLINE
48
48
}
49
49
50
+ regexPrefix = "(?<![\\ w])("
51
+ regexSuffix = ")(?![\\ w])"
52
+
50
53
def highlight (self , view , regex , regionName , scope , icon , regionFlags ):
51
54
if (regex == "" ) or (regex == None ):
52
55
return []
@@ -57,7 +60,7 @@ def highlight(self, view, regex, regionName, scope, icon, regionFlags):
57
60
if (numFoundRegions > 0 ):
58
61
# Expand all regions to match the whole line and mark the line with the given scpe
59
62
for i in range (0 , numFoundRegions ):
60
- foundRegions [i ] = view .expand_by_class (foundRegions [i ], sublime . CLASS_LINE_START | sublime . CLASS_LINE_END )
63
+ foundRegions [i ] = view .line (foundRegions [i ])
61
64
view .add_regions (regionName , foundRegions , scope , "Packages/LogView/" + icon + ".png" , regionFlags );
62
65
63
66
return foundRegions
@@ -68,13 +71,20 @@ def markupView(self, view, statusAnimation):
68
71
errorRegex = settings .get ("error_filter" , "error|fail|exception" )
69
72
errorScope = settings .get ("error_scope" , "markup.deleted" )
70
73
errorStatusCaption = settings .get ("error_status_caption" , "Errors" )
71
- warningRegex = settings .get ("warning_filter" , "warning|not found|[^\w] defer" )
74
+ warningRegex = settings .get ("warning_filter" , "warning|not found|defer(ed)? " )
72
75
warningScope = settings .get ("warning_scope" , "markup.changed" )
73
76
warningStatusCaption = settings .get ("warning_status_caption" , "Warnings" )
74
- markRegex = settings .get ("mark_filter" , "[^\w]( start| quit|end|shut(ing)* down)[^\w] " )
77
+ markRegex = settings .get ("mark_filter" , "start(ing|ed)?| quit|end|shut(ing)? down" )
75
78
markScope = settings .get ("mark_scope" , "markup.inserted" )
76
79
markStatusCaption = settings .get ("mark_status_caption" , "Marks" )
77
80
highlighStyle = settings .get ("highlight_style" , "underline" )
81
+ autoMatchWords = settings .get ("auto_match_words" , True )
82
+
83
+ # If auto_match_words is set to true, extend the regular expressions with lookarounds to only match words.
84
+ if (autoMatchWords ):
85
+ errorRegex = self .regexPrefix + errorRegex + self .regexSuffix
86
+ warningRegex = self .regexPrefix + warningRegex + self .regexSuffix
87
+ markRegex = self .regexPrefix + markRegex + self .regexSuffix
78
88
79
89
# Determin the falgs to set on the region for correct highlighting
80
90
if (highlighStyle in self .regionStyles ):
@@ -94,7 +104,7 @@ def markupView(self, view, statusAnimation):
94
104
del foundRegions
95
105
96
106
# Set a bookmark for each region
97
- view .add_regions ("bookmarks" , bookmarks , "bookmarks" , "bookmark " , sublime .HIDDEN );
107
+ view .add_regions ("bookmarks" , bookmarks , "bookmarks" , "" , sublime .HIDDEN );
98
108
del bookmarks
99
109
100
110
# Stop the animation
@@ -141,9 +151,6 @@ def on_clone(self, view):
141
151
if (view .settings ().get ('syntax' ) == "Packages/LogView/logview.tmLanguage" ):
142
152
self .prepareView (view )
143
153
144
- def on_reload (self , view ):
145
- print ("reload" )
146
-
147
154
# Called if a text command is executed on the buffer
148
155
def on_text_command (self , view , command_name , args ):
149
156
if (command_name == "set_file_type" ):
0 commit comments