Changeset 786 in code for trunk


Ignore:
Timestamp:
Feb 25, 2022, 10:32:09 AM (3 years ago)
Author:
contact
Message:

irc: simplify isHighlight

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/irc.go

    r784 r786  
    682682func isWordBoundary(r rune) bool {
    683683        switch r {
    684         case '-', '_', '|':
     684        case '-', '_', '|': // inspired from weechat.look.highlight_regex
    685685                return false
    686         case '\u00A0':
    687                 return true
    688686        default:
    689687                return !unicode.IsLetter(r) && !unicode.IsNumber(r)
     
    698696                }
    699697
    700                 // Detect word boundaries
    701                 var left, right rune
    702                 if i > 0 {
    703                         left, _ = utf8.DecodeLastRuneInString(text[:i])
    704                 }
    705                 if i < len(text) {
    706                         right, _ = utf8.DecodeRuneInString(text[i+len(nick):])
    707                 }
     698                left, _ := utf8.DecodeLastRuneInString(text[:i])
     699                right, _ := utf8.DecodeRuneInString(text[i+len(nick):])
    708700                if isWordBoundary(left) && isWordBoundary(right) {
    709701                        return true
Note: See TracChangeset for help on using the changeset viewer.