mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-14 18:12:05 +08:00
Fix issue #1070: autocomplete pops up in string
This commit is contained in:
@ -4833,7 +4833,12 @@ var
|
|||||||
tablename : WideString;
|
tablename : WideString;
|
||||||
rx : TRegExpr;
|
rx : TRegExpr;
|
||||||
PrevShortToken,
|
PrevShortToken,
|
||||||
PrevLongToken : WideString;
|
PrevLongToken,
|
||||||
|
Token : WideString;
|
||||||
|
Start,
|
||||||
|
TokenTypeInt : Integer;
|
||||||
|
Attri : TSynHighlighterAttributes;
|
||||||
|
Editor : TCustomSynEdit;
|
||||||
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';
|
||||||
|
|
||||||
@ -4885,6 +4890,13 @@ const
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
Editor := (Sender as TSynCompletionProposal).Editor;
|
||||||
|
Editor.GetHighlighterAttriAtRowColEx(Editor.CaretXY, Token, TokenTypeInt, Start, Attri);
|
||||||
|
if TtkTokenKind(TokenTypeInt) = tkString then begin
|
||||||
|
CanExecute := False;
|
||||||
|
Exit;
|
||||||
|
end;
|
||||||
|
|
||||||
SynCompletionProposal1.InsertList.Clear;
|
SynCompletionProposal1.InsertList.Clear;
|
||||||
SynCompletionProposal1.ItemList.Clear;
|
SynCompletionProposal1.ItemList.Clear;
|
||||||
PrevShortToken := SynCompletionProposal1.PreviousToken;
|
PrevShortToken := SynCompletionProposal1.PreviousToken;
|
||||||
@ -4892,9 +4904,9 @@ begin
|
|||||||
|
|
||||||
rx := TRegExpr.Create;
|
rx := TRegExpr.Create;
|
||||||
|
|
||||||
// Find longer token, ignore EndOfTokenChars, just the last chars up to a whitespace
|
// Find longer token, ignore EndOfTokenChars, just the last chars up to a whitespace
|
||||||
rx.Expression := '(\S+).$';
|
rx.Expression := '(\S+).$';
|
||||||
PrevLongToken := Copy(SynCompletionProposal1.Editor.LineText, 0, x);
|
PrevLongToken := Copy(Editor.LineText, 0, x);
|
||||||
if rx.Exec(PrevLongToken) then
|
if rx.Exec(PrevLongToken) then
|
||||||
PrevLongToken := rx.Match[1]
|
PrevLongToken := rx.Match[1]
|
||||||
else
|
else
|
||||||
@ -4906,14 +4918,14 @@ 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(SynCompletionProposal1.Editor.Text);
|
j := Length(Editor.Text);
|
||||||
for i := SynCompletionProposal1.Editor.SelStart+1024 downto SynCompletionProposal1.Editor.SelStart-1024 do
|
for i := Editor.SelStart+1024 downto Editor.SelStart-1024 do
|
||||||
begin
|
begin
|
||||||
if i > j then
|
if i > j then
|
||||||
continue;
|
continue;
|
||||||
if i < 1 then
|
if i < 1 then
|
||||||
break;
|
break;
|
||||||
sql := SynCompletionProposal1.Editor.Text[i] + sql;
|
sql := Editor.Text[i] + sql;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
// 2. Parse FROM clause to detect relevant table/view, probably aliased
|
// 2. Parse FROM clause to detect relevant table/view, probably aliased
|
||||||
|
Reference in New Issue
Block a user