Pārlūkot izejas kodu

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 gadu atpakaļ
vecāks
revīzija
62778baaca
1 mainītis faili ar 5 papildinājumiem un 1 dzēšanām
  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;
 function TCompileForm.InitiateAutoCompleteOrCallTipAllowedAtPos(const AMemo: TCompScintEdit;
   const WordStartLinePos, PositionBeforeWordStartPos: Integer): Boolean;
   const WordStartLinePos, PositionBeforeWordStartPos: Integer): Boolean;
 begin
 begin
-  Result := (PositionBeforeWordStartPos >= WordStartLinePos) and
+  Result := (PositionBeforeWordStartPos < WordStartLinePos) or
             not FMemosStyler.IsCommentOrPascalStringStyle(AMemo.GetStyleAtPosition(PositionBeforeWordStartPos));
             not FMemosStyler.IsCommentOrPascalStringStyle(AMemo.GetStyleAtPosition(PositionBeforeWordStartPos));
 end;
 end;
 
 
@@ -4932,6 +4932,10 @@ begin
       begin
       begin
         Section := FMemosStyler.GetSectionFromLineState(FActiveMemo.Lines.State[Line]);
         Section := FMemosStyler.GetSectionFromLineState(FActiveMemo.Lines.State[Line]);
         if Section = scCode then begin
         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);
           var PositionBeforeWordStartPos := FActiveMemo.GetPositionBefore(WordStartPos);
           if Key <> #0 then begin
           if Key <> #0 then begin
             FActiveMemo.StyleNeeded(PositionBeforeWordStartPos); { Make sure the typed character has been styled }
             FActiveMemo.StyleNeeded(PositionBeforeWordStartPos); { Make sure the typed character has been styled }