@@ -192,35 +192,26 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
192
192
if ( string . IsNullOrEmpty ( subject ) )
193
193
return ;
194
194
195
- var offset = 0 ;
196
195
var keywordMatch = REG_KEYWORD_FORMAT1 ( ) . Match ( subject ) ;
197
196
if ( ! keywordMatch . Success )
198
197
keywordMatch = REG_KEYWORD_FORMAT2 ( ) . Match ( subject ) ;
199
198
200
- if ( keywordMatch . Success )
201
- {
202
- var keyword = new Run ( subject . Substring ( 0 , keywordMatch . Length ) ) ;
203
- keyword . FontWeight = FontWeight . Bold ;
204
- Inlines . Add ( keyword ) ;
205
-
206
- offset = keywordMatch . Length ;
207
- subject = subject . Substring ( offset ) ;
208
- }
209
-
210
- var rules = IssueTrackerRules ;
211
- if ( rules == null || rules . Count == 0 )
212
- {
213
- Inlines . Add ( new Run ( subject ) ) ;
214
- return ;
215
- }
216
-
199
+ var rules = IssueTrackerRules ?? [ ] ;
217
200
var matches = new List < Models . Hyperlink > ( ) ;
218
201
foreach ( var rule in rules )
219
202
rule . Matches ( matches , subject ) ;
220
203
221
204
if ( matches . Count == 0 )
222
205
{
223
- Inlines . Add ( new Run ( subject ) ) ;
206
+ if ( keywordMatch . Success )
207
+ {
208
+ Inlines . Add ( new Run ( subject . Substring ( 0 , keywordMatch . Length ) ) { FontWeight = FontWeight . Bold } ) ;
209
+ Inlines . Add ( new Run ( subject . Substring ( keywordMatch . Length ) ) ) ;
210
+ }
211
+ else
212
+ {
213
+ Inlines . Add ( new Run ( subject ) ) ;
214
+ }
224
215
return ;
225
216
}
226
217
@@ -232,18 +223,44 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
232
223
foreach ( var match in matches )
233
224
{
234
225
if ( match . Start > pos )
235
- inlines . Add ( new Run ( subject . Substring ( pos , match . Start - pos ) ) ) ;
226
+ {
227
+ if ( keywordMatch . Success && pos < keywordMatch . Length )
228
+ {
229
+ if ( keywordMatch . Length < match . Start )
230
+ {
231
+ inlines . Add ( new Run ( subject . Substring ( pos , keywordMatch . Length - pos ) ) { FontWeight = FontWeight . Bold } ) ;
232
+ inlines . Add ( new Run ( subject . Substring ( keywordMatch . Length , match . Start - keywordMatch . Length ) ) ) ;
233
+ }
234
+ else
235
+ {
236
+ inlines . Add ( new Run ( subject . Substring ( pos , match . Start - pos ) ) { FontWeight = FontWeight . Bold } ) ;
237
+ }
238
+ }
239
+ else
240
+ {
241
+ inlines . Add ( new Run ( subject . Substring ( pos , match . Start - pos ) ) ) ;
242
+ }
243
+ }
236
244
237
245
var link = new Run ( subject . Substring ( match . Start , match . Length ) ) ;
238
246
link . Classes . Add ( "issue_link" ) ;
239
247
inlines . Add ( link ) ;
240
248
241
249
pos = match . Start + match . Length ;
242
- match . Start += offset ; // Because we use this index of whole subject to detect mouse event.
243
250
}
244
251
245
252
if ( pos < subject . Length )
246
- inlines . Add ( new Run ( subject . Substring ( pos ) ) ) ;
253
+ {
254
+ if ( keywordMatch . Success && pos < keywordMatch . Length )
255
+ {
256
+ inlines . Add ( new Run ( subject . Substring ( pos , keywordMatch . Length - pos ) ) { FontWeight = FontWeight . Bold } ) ;
257
+ inlines . Add ( new Run ( subject . Substring ( keywordMatch . Length ) ) ) ;
258
+ }
259
+ else
260
+ {
261
+ inlines . Add ( new Run ( subject . Substring ( pos ) ) ) ;
262
+ }
263
+ }
247
264
248
265
Inlines . AddRange ( inlines ) ;
249
266
}
0 commit comments