SQL completion proposal: Be more exact when detecting the current query and its table aliases, don't mix that up with a potential following or preceding query. See also http://www.heidisql.com/forum/viewtopic.php?p=3419

This commit is contained in:
Ansgar Becker
2009-08-07 16:41:40 +00:00
parent 386187b99d
commit 62dbda76ff

View File

@ -4456,6 +4456,7 @@ var
TokenTypeInt : Integer; TokenTypeInt : Integer;
Attri : TSynHighlighterAttributes; Attri : TSynHighlighterAttributes;
Editor : TCustomSynEdit; Editor : TCustomSynEdit;
Queries : TWideStringList;
const const
ItemPattern: WideString = '\image{%d}\hspace{5}\color{clSilver}%s\column{}\color{clWindowText}%s'; ItemPattern: WideString = '\image{%d}\hspace{5}\color{clSilver}%s\column{}\color{clWindowText}%s';
@ -4535,15 +4536,16 @@ begin
// spaces are not detected correctly. // spaces are not detected correctly.
// 1. find the currently edited sql-statement around the cursor position in synmemo // 1. find the currently edited sql-statement around the cursor position in synmemo
j := Length(Editor.Text); Queries := parsesql(Editor.Text);
for i := Editor.SelStart+1024 downto Editor.SelStart-1024 do j := 0;
begin for i:=0 to Queries.Count-1 do begin
if i > j then Inc(j, Length(Queries[i])+1);
continue; if (j >= Editor.SelStart) or (i = Queries.Count-1) then begin
if i < 1 then sql := Queries[i];
break; break;
sql := Editor.Text[i] + sql; end;
end; end;
FreeAndNil(Queries);
// 2. Parse FROM clause to detect relevant table/view, probably aliased // 2. Parse FROM clause to detect relevant table/view, probably aliased
rx.ModifierG := True; rx.ModifierG := True;