@@ -44,7 +44,7 @@ TNppPluginHTMLTag = class(TNppPlugin)
4444 procedure LoadOptions ;
4545 procedure SaveOptions ;
4646 procedure FindAndDecode (const KeyCode: Integer; Cmd: TDecodeCmd = dcAuto);
47- procedure AutoCompleteMatchingTag (const StartPos: Sci_Position; TagName: nppPChar);
47+ function AutoCompleteMatchingTag (const StartPos: Sci_Position; TagName: nppPChar): Boolean ;
4848 public
4949 constructor Create;
5050 destructor Destroy; override;
@@ -273,7 +273,8 @@ procedure TNppPluginHTMLTag.DoAutoCSelection({%H-}const hwnd: HWND; const StartP
273273 if not SupportsBigFiles then
274274 Exit;
275275{ $ENDIF}
276- AutoCompleteMatchingTag(StartPos, ListItem);
276+ if AutoCompleteMatchingTag(StartPos, ListItem) then
277+ App.ActiveDocument.SendMessage(SCI_AUTOCCANCEL);
277278end ;
278279
279280{ ------------------------------------------------------------------------------------------------ }
@@ -657,18 +658,20 @@ procedure TNppPluginHTMLTag.FindAndDecode(const KeyCode: Integer; Cmd: TDecodeCm
657658end ;
658659
659660{ ------------------------------------------------------------------------------------------------ }
660- procedure TNppPluginHTMLTag.AutoCompleteMatchingTag (const StartPos: Sci_Position; TagName: nppPChar);
661+ function TNppPluginHTMLTag.AutoCompleteMatchingTag (const StartPos: Sci_Position; TagName: nppPChar): Boolean ;
661662const
662663 MaxTagLength = 72 ; { https://www.rfc-editor.org/rfc/rfc1866#section-3.2.3 }
663664var
664665 Doc: TActiveDocument;
665666 TagEnd: TTextRange;
666667 NewTagName: PAnsiChar;
667668begin
669+ Result := False;
668670 Doc := App.ActiveDocument;
669671 NewTagName := PAnsiChar(UTF8Encode(nppString(TagName)));
670672
671- if (Doc.SelectionMode <> smStreamMulti) or (Length(NewTagName) > MaxTagLength) then
673+ if not (Doc.Language in [L_HTML, L_XML, L_PHP, L_ASP, L_JSP]) or
674+ (Doc.SelectionMode <> smStreamMulti) or (Length(NewTagName) > MaxTagLength) then
672675 Exit;
673676
674677 try
@@ -677,6 +680,7 @@ procedure TNppPluginHTMLTag.AutoCompleteMatchingTag(const StartPos: Sci_Position
677680 if TagEnd.Length <> 0 then begin
678681 CommandSelectMatchingTags;
679682 Doc.ReplaceSelection(TagName);
683+ Result := True;
680684 end ;
681685 finally
682686 FreeAndNil(TagEnd);
0 commit comments