@@ -467,14 +467,15 @@ bool autoCompleteMatchingTag(const Sci_Position startPos, const char *tagName) {
467467// --------------------------------------------------------------------------------------
468468void findAndDecode (const int keyCode, DecodeCmd cmd) {
469469 using Decoder = int (*)();
470+ SciActiveDocument doc = plugin.editor ().activeDocument ();
470471 int ch = keyCode & 0xff ;
471472
472- if ((cmd == dcAuto) && (!(plugin.options .liveEntityDecoding || plugin.options .liveUnicodeDecoding ) ||
473+ if ((cmd == dcAuto) && ((ch == 0x0D && doc.sendMessage (SCI_GETEOLMODE) == SC_EOL_CRLF) ||
474+ !(plugin.options .liveEntityDecoding || plugin.options .liveUnicodeDecoding ) ||
473475 !((ch >= 0x09 && ch <= 0x0D ) || ch == 0x20 ))) {
474476 return ;
475477 }
476478
477- SciActiveDocument doc = plugin.editor ().activeDocument ();
478479 Sci_Position caret = doc.currentPosition (), charOffset = -1 , anchor, selStart, nextCaretPos;
479480 bool didReplace = false ;
480481
@@ -492,11 +493,15 @@ void findAndDecode(const int keyCode, DecodeCmd cmd) {
492493 int chCurrent = static_cast <int >(doc.sendMessage (SCI_GETCHARAT, anchor));
493494 if (chCurrent >= 0 && chCurrent <= 0x20 )
494495 break ;
495- if (chCurrent == ' &' && (plugin.options .liveEntityDecoding || cmd == dcEntity)) { // Handle entities
496- didReplace = replace (Entities::decode, anchor, caret);
497- if (!(ch == 0x0A || ch == 0x0D ))
498- ++charOffset;
499- break ;
496+ else if (plugin.options .liveEntityDecoding || cmd == dcEntity) {
497+ if (anchor == (caret - 1 ) && chCurrent != ' ;' ) // No adjacent entity here
498+ break ;
499+ else if (chCurrent == ' &' ) { // Handle entities
500+ didReplace = replace (Entities::decode, anchor, caret);
501+ if (!(ch == 0x0A || ch == 0x0D ))
502+ ++charOffset;
503+ break ;
504+ }
500505 } else if (chCurrent == plugin.options .unicodePrefix [0 ] &&
501506 (plugin.options .liveUnicodeDecoding || cmd == dcUnicode)) { // Handle Unicode
502507 size_t lenPrefix = plugin.options .unicodePrefix .size ();
0 commit comments