Skip to content
Permalink
Browse files

If previous word is preceded by a dot, it is most probably a table, c…

…olumn or some alias, so do not uppercase it then. Closes #494
  • Loading branch information...
ansgarbecker committed Mar 9, 2019
1 parent d6c35d9 commit 098c526b15cef8af98d1cf00ef4a92aa4de0f0db
Showing with 10 additions and 1 deletion.
  1. +10 −1 source/main.pas
@@ -6254,18 +6254,27 @@ procedure TMainForm.SynMemoQueryKeyPress(Sender: TObject; var Key: Char);
OldCaretXY, StartOfTokenRowCol, CurrentRowCol: TBufferCoord;
TokenTypeInt, Start, CurrentCharIndex: Integer;
OldSelStart, OldSelEnd: Integer;
LineWithToken: String;
const
WordChars = ['A'..'Z', 'a'..'z', '_'];
IgnoreChars = [#8]; // Backspace, and probably more which should not trigger uppercase
begin
// Uppercase reserved words, functions and data types
if AppSettings.ReadBool(asAutoUppercase) and (not CharInSet(Key, WordChars)) then begin
if (not CharInSet(Key, WordChars)) and (not CharInSet(Key, IgnoreChars)) then begin
if not AppSettings.ReadBool(asAutoUppercase) then
Exit;
Editor := Sender as TSynMemo;
CurrentCharIndex := Editor.RowColToCharIndex(Editor.CaretXY);
// Go one left on trailing line feed, after which PrevWordPos doesn't work
Dec(CurrentCharIndex, 1);
CurrentRowCol := Editor.CharIndexToRowCol(CurrentCharIndex);
StartOfTokenRowCol := Editor.PrevWordPosEx(CurrentRowCol);
Editor.GetHighlighterAttriAtRowColEx(StartOfTokenRowCol, Token, TokenTypeInt, Start, Attri);
LineWithToken := Editor.Lines[StartOfTokenRowCol.Line-1];
if (StartOfTokenRowCol.Char > 1) and (LineWithToken[StartOfTokenRowCol.Char-1] = '.') then begin
// Previous word is preceded by a dot, so it is most probably a table, column or some alias
Exit;
end;
if SynSQLSynUsed.TableNames.IndexOf(Token) > 0 then
Exit;
if not (TtkTokenKind(TokenTypeInt) in [tkDatatype, tkFunction, tkKey]) then

0 comments on commit 098c526

Please sign in to comment.
You can’t perform that action at this time.