Browse Source

Improve [Code] autocomple initiation: do not initiate when just indenting the line, do initiate when a word char is added at the start of the line. The first is similar to what it already did for other sections. Can perhaps be smarted instead of just requiring non whitespace?

Martijn Laan 1 year ago
parent
commit
62778baaca
1 changed files with 5 additions and 1 deletions
  1. 5 1
      Projects/Src/Compil32/CompForm.pas

+ 5 - 1
Projects/Src/Compil32/CompForm.pas

@@ -4846,7 +4846,7 @@ end;
 function TCompileForm.InitiateAutoCompleteOrCallTipAllowedAtPos(const AMemo: TCompScintEdit;
   const WordStartLinePos, PositionBeforeWordStartPos: Integer): Boolean;
 begin
-  Result := (PositionBeforeWordStartPos >= WordStartLinePos) and
+  Result := (PositionBeforeWordStartPos < WordStartLinePos) or
             not FMemosStyler.IsCommentOrPascalStringStyle(AMemo.GetStyleAtPosition(PositionBeforeWordStartPos));
 end;
 
@@ -4932,6 +4932,10 @@ begin
       begin
         Section := FMemosStyler.GetSectionFromLineState(FActiveMemo.Lines.State[Line]);
         if Section = scCode then begin
+          { Space can only initiate autocompletion after non whitespace }
+          if (Key = ' ') and OnlyWhiteSpaceBeforeWord(FActiveMemo, LinePos, WordStartPos) then
+            Exit;
+
           var PositionBeforeWordStartPos := FActiveMemo.GetPositionBefore(WordStartPos);
           if Key <> #0 then begin
             FActiveMemo.StyleNeeded(PositionBeforeWordStartPos); { Make sure the typed character has been styled }