@@ -6838,32 +6838,32 @@ procedure TMainForm.SynCompletionProposalCodeCompletion(var Value: string;
68386838var
68396839 Proposal: TSynCompletion;
68406840 rx: TRegExpr;
6841- ImageIndex, f: Integer;
6841+ ImageIndex, f, PropIndex: Integer;
6842+ PropItem: TProposalItem;
68426843 FunctionDeclaration: String;
68436844begin
68446845 Proposal := SynCompletionProposal;
68456846 // Surround identifiers with backticks if it is a column, table, routine, db
68466847 rx := TRegExpr.Create;
6847- rx.Expression := '\\image\{(\d+)\}';
6848- if rx.Exec(Proposal.ItemList[{Proposal.Index}0]) then begin
6849- ImageIndex := MakeInt(rx.Match[1]);
6850- if not (ImageIndex in [ICONINDEX_KEYWORD, ICONINDEX_FUNCTION, 113]) then begin
6851- FunctionDeclaration := '';
6852- f := Pos('(', Value);
6853- if f > 0 then begin
6854- FunctionDeclaration := Copy(Value, f, Length(Value));
6855- Delete(Value, f, Length(Value));
6856- end;
6857-
6858- rx.Expression := '^(['+QuoteRegExprMetaChars(ActiveConnection.QuoteChars)+'])(.*)$';
6859- if rx.Exec(Value) then begin
6860- // Left character of identifier is already a quote: user wants to force quoting.
6861- // Seperate that left quote character away from what gets now quoted automatically, and force quoting
6862- Value := ActiveConnection.QuoteIdent(rx.Match[2], True) + FunctionDeclaration;
6863- end else begin
6864- // Identifier without left quote - quote when required
6865- Value := ActiveConnection.QuoteIdent(Value, False) + FunctionDeclaration;
6866- end;
6848+ PropIndex := Proposal.IndexFromVisibleIndex(Proposal.Position);
6849+ PropItem := FProposalItems[PropIndex];
6850+ if not (PropItem.ImageIndex in [ICONINDEX_KEYWORD, ICONINDEX_FUNCTION, 113]) then begin
6851+ FunctionDeclaration := '';
6852+ f := Pos('(', Value);
6853+ if f > 0 then begin
6854+ FunctionDeclaration := Copy(Value, f, Length(Value));
6855+ Delete(Value, f, Length(Value));
6856+ end;
6857+
6858+ rx.Expression := '^(['+QuoteRegExprMetaChars(ActiveConnection.QuoteChars)+'])(.*)$';
6859+ if rx.Exec(Value) then begin
6860+ // Left character of identifier is already a quote: user wants to force quoting.
6861+ // Seperate that left quote character away from what gets now quoted automatically, and force quoting
6862+ Value := ActiveConnection.QuoteIdent(rx.Match[2], True) + FunctionDeclaration;
6863+ Value := Copy(Value, 2, MaxInt); // Editor already contains leading quote
6864+ end else begin
6865+ // Identifier without left quote - quote when required
6866+ Value := ActiveConnection.QuoteIdent(Value, False) + FunctionDeclaration;
68676867 end;
68686868 end;
68696869 rx.Free;
@@ -6937,6 +6937,7 @@ procedure TMainForm.SynCompletionProposalExecute(Sender: TObject);
69376937 Key: TTableKey;
69386938 Obj: TDBObject;
69396939 ColumnIcon: Integer;
6940+ PropItem: TProposalItem;
69406941 begin
69416942 dbname := '';
69426943 tblname := LeftToken;
@@ -6964,10 +6965,9 @@ procedure TMainForm.SynCompletionProposalExecute(Sender: TObject);
69646965 end;
69656966 end;
69666967 // Put formatted text and icon into proposal
6967- //if CurrentInput.StartsWith(Conn.QuoteChar) then
6968- // Proposal.ItemList.Add(Conn.QuoteChar + Col.Name)
6969- //else
6970- FProposalItems.AddNew(Col.Name, ColumnIcon, LowerCase(Col.DataType.Name), Col.Name, Col.Comment, AppColorSchemes.First.GridNullColors[Col.DataType.Category]);
6968+ PropItem := FProposalItems.AddNew(Col.Name, ColumnIcon, LowerCase(Col.DataType.Name), Col.Name, Col.Comment, AppColorSchemes.First.GridNullColors[Col.DataType.Category]);
6969+ if Proposal.CurrentString.StartsWith(Conn.QuoteChar) then
6970+ PropItem.InsertText := Conn.QuoteChar + Col.Name;
69716971 Inc(ColumnsInList);
69726972 end;
69736973 Columns.Free;
0 commit comments