diff --git a/Projects/Simba/framescript.pas b/Projects/Simba/framescript.pas index 2f5f4ec..b295705 100644 --- a/Projects/Simba/framescript.pas +++ b/Projects/Simba/framescript.pas @@ -187,12 +187,14 @@ begin try SynEdit.GetWordBoundsAtRowCol(SynEdit.CaretXY, sp, ep); - s := SynEdit.Lines[SynEdit.Carety-1]; - if ep > length(s) then //We are outside the real text, go back to the last char - mp.Run(ms, nil, Synedit.SelStart - ep + length(s),false) + if (SynEdit.CaretY <= 0) or (SynEdit.CaretY > SynEdit.Lines.Count) then + s := '' else - mp.Run(ms, nil, Synedit.SelStart + (ep - Synedit.CaretX) - 1,false); - mp.Position := SynEdit.SelStart + (ep - SynEdit.CaretX) - 1; + s := SynEdit.Lines[SynEdit.CaretY - 1]; + if ep > length(s) then //We are outside the real text, go back to the last char + mp.Run(ms, nil, Synedit.SelStart + (Length(s) - Synedit.CaretX)) + else + mp.Run(ms, nil, Synedit.SelStart + (ep - Synedit.CaretX) - 1); d := mp.FindVarBase(mp.GetExpressionAtPos); if (d <> nil) then @@ -278,15 +280,14 @@ begin end; end; -procedure TScriptFrame.SynEditKeyDown(Sender: TObject; var Key: Word; - Shift: TShiftState); +procedure TScriptFrame.SynEditKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if key = VK_F3 then begin; SimbaForm.ActionFindNextExecute(Sender); key := 0; - end; - if key = VK_ESCAPE then + end + else if key = VK_ESCAPE then SimbaForm.ParamHint.Hide; SimbaForm.CodeCompletionForm.HandleKeyDown(Sender, Key, Shift); @@ -360,7 +361,7 @@ begin if (SynEdit.CaretY <= 0) or (SynEdit.CaretY > SynEdit.Lines.Count) then s := '' else - s := SynEdit.Lines[SynEdit.Carety - 1]; + s := SynEdit.Lines[SynEdit.CaretY - 1]; if ep > length(s) then //We are outside the real text, go back to the last char mp.Run(ms, nil, Synedit.SelStart + (Length(s) - Synedit.CaretX) + 1) else diff --git a/Units/Misc/v_autocompleteform.pas b/Units/Misc/v_autocompleteform.pas index 4cbc270..3f6c5da 100644 --- a/Units/Misc/v_autocompleteform.pas +++ b/Units/Misc/v_autocompleteform.pas @@ -5,7 +5,7 @@ interface {$I ValistusDefines.inc} uses - Classes, SysUtils, Forms, Controls, Graphics, Dialogs, + Classes, SysUtils, Forms, Controls, Graphics, StdCtrls, ExtCtrls, SynEdit, SynEditKeyCmds, v_ideCodeParser, v_ideCodeInsight, {$IFDEF FPC} @@ -597,14 +597,12 @@ begin; if EndPos.y = beginpos.y then begin result := copy(strings[beginpos.y], beginpos.x, endpos.x - beginpos.x + 1); - //ShowMessage(Result); exit; end; result := copy(strings[beginpos.y],beginpos.x, length(strings[beginpos.y]) - beginpos.x + 1); for i := beginpos.y + 1 to endpos.y-1 do result := result + strings[i]; result := result + copy(strings[endpos.y], 1, endpos.x - 1); //Position <> count! - //ShowMessage(Result); end; function TParamHint.PrepareParamString(out Str: string; out MustHide : boolean): Integer; @@ -739,7 +737,6 @@ begin inherited Destroy; end; - constructor TParamHint.Create(TheOwner: TComponent); begin inherited; @@ -1007,9 +1004,13 @@ end; procedure TParamHint.ApplicationIdle(Sender: TObject; var Done: Boolean); begin - if not Visible then exit; - UpdateHint; - Sleep(1); + if (not Visible) then exit; + try + UpdateHint; + Sleep(1); + except + Hide; + end; end; end. diff --git a/Units/Misc/v_ideCodeInsight.pas b/Units/Misc/v_ideCodeInsight.pas index 19e974a..938edc8 100644 --- a/Units/Misc/v_ideCodeInsight.pas +++ b/Units/Misc/v_ideCodeInsight.pas @@ -728,7 +728,7 @@ begin if (EndPos > Length(s)) then Result := '' else - Result := CompressWhiteSpace(Copy(s, StartPos + 1, EndPos - StartPos - 1)); + Result := CompressWhiteSpace(Copy(s, StartPos + 1, EndPos - StartPos)); end; function TCodeInsight.GetExpressionAtPos(var BraceCount, BracketCount, CommaCount: Integer; IgnoreBrackets: Boolean = False): string;