The hilight algorithm inserts color control codes to turn the desired text into the hilight color. Unfortunately, in retrieving what it thinks is the previous color control code, it ignores several codes (such as ^o (15) which resets colors). Thus, when in the presence of another script or a specially-formatted message (eg. from a bot that reports commits to a repo, giving different colors for username, branch, message, etc), it restores the previously used color.
ie.
^c5color^o plain Zannick should be plain
becomes
^c5color^o plain ^c8Zannick^c5 should be plain
where "should be plain" is colored red
A simplistic way to fix this for ^o would be to expand the else case in strip_real_length (which is where irssi finds the last color control code) to something like
though this will still be wrong in the general case, since some of the control characters (eg. ^b ^f ^g ^v ^7) are toggles (and they do not remove the color from the hilight, either).
I'd suggest something more complicated where the toggles are tracked, and then hilight-text adds a ^o followed by the appropriate control characters:
^bbold Zannick still bold -> ^bbold ^c8Zannick^o^b still bold
The hilight algorithm inserts color control codes to turn the desired text into the hilight color. Unfortunately, in retrieving what it thinks is the previous color control code, it ignores several codes (such as ^o (15) which resets colors). Thus, when in the presence of another script or a specially-formatted message (eg. from a bot that reports commits to a repo, giving different colors for username, branch, message, etc), it restores the previously used color.
ie.
^c5color^o plain Zannick should be plain becomes ^c5color^o plain ^c8Zannick^c5 should be plain where "should be plain" is colored red
Examples (where a script colors other users' nicks and irssi hilights mine): http://imgur.com/MdgxbMX,0SN8TuO
A simplistic way to fix this for ^o would be to expand the else case in strip_real_length (which is where irssi finds the last color control code) to something like
if (IS_COLOR_CODE(str)) { last_color_pos = (int)(str-start); *last_color_len = 1; } else { [previous stuff...] }
though this will still be wrong in the general case, since some of the control characters (eg. ^b ^f ^g ^v ^7) are toggles (and they do not remove the color from the hilight, either).
I'd suggest something more complicated where the toggles are tracked, and then hilight-text adds a ^o followed by the appropriate control characters: ^bbold Zannick still bold -> ^bbold ^c8Zannick^o^b still bold