diff --git a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp
index 6b9855bc7..e1da03b1e 100644
--- a/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp
+++ b/PowerEditor/src/ScitillaComponent/AutoCompletion.cpp
@@ -370,6 +370,17 @@ bool AutoCompletion::showFunctionComplete()
void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t caretPos, bool isHTML)
{
+ char prev = (char)_pEditView->execute(SCI_GETCHARAT, caretPos - 2);
+ char prevprev = (char)_pEditView->execute(SCI_GETCHARAT, caretPos - 3);
+
+ // Closing a tag (i.e. "-->") will be ignored
+ if (prevprev == '-' && prev == '-')
+ return;
+
+ // "" and "" will be ignored
+ if (prev == '/')
+ return;
+
int flags = SCFIND_REGEXP | SCFIND_POSIX;
_pEditView->execute(SCI_SETSEARCHFLAGS, flags);
TCHAR tag2find[] = TEXT("<[^\\s>]*");
@@ -407,12 +418,6 @@ void AutoCompletion::getCloseTag(char *closeTag, size_t closeTagSize, size_t car
}
}
- char tagTail[2];
- _pEditView->getText(tagTail, caretPos-2, caretPos-1);
-
- if (tagTail[0] == '/') // "" and "" will be ignored
- return;
-
closeTag[0] = '<';
closeTag[1] = '/';
_pEditView->getText(closeTag + 2, targetStart + 1, targetEnd);