Skip to content

Commit 7d7b78f

Browse files
committedAug 15, 2016
Merge latest changes from official SynEdit repository. Fixes slow highlighter when TableNames contains several 1000's of strings. Removes limitation to 1000 table names for highlighting. See
* http://www.heidisql.com/forum.php?t=16307 * SynEdit/SynEdit#28
1 parent 5534275 commit 7d7b78f

17 files changed

+77
-11
lines changed
 

‎components/synedit/Source/SynAutoCorrectEditor.pas

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ interface
5050
QSynAutoCorrect,
5151
QSynUnicode,
5252
{$ELSE}
53+
{$IFDEF SYN_COMPILER_17_UP}
54+
Types,
55+
{$ENDIF}
5356
Windows, Messages, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls,
5457
Buttons, Registry,
5558
SynAutoCorrect,

‎components/synedit/Source/SynCompletionProposal.pas

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ interface
6868
QSynEdit,
6969
QSynUnicode,
7070
{$ELSE}
71+
{$IFDEF SYN_COMPILER_17_UP}
72+
Types, UITypes,
73+
{$ENDIF}
7174
Windows,
7275
Messages,
7376
Graphics,

‎components/synedit/Source/SynDBEdit.pas

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ procedure TCustomDBSynEdit.CMExit(var Msg: TCMExit);
256256

257257
procedure TCustomDBSynEdit.CMGetDataLink(var Msg: TMessage);
258258
begin
259-
Msg.Result := Integer(FDataLink);
259+
Msg.Result := LRESULT(FDataLink);
260260
end;
261261
{$ENDIF}
262262

‎components/synedit/Source/SynEdit.pas

+4-2
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ interface
8383
Themes,
8484
{$ENDIF}
8585
{$IFDEF SYN_COMPILER_17_UP}
86-
UITypes,
86+
Types, UITypes,
8787
{$ENDIF}
8888
SynUnicode,
8989
{$ENDIF}
@@ -1564,7 +1564,7 @@ procedure TCustomSynEdit.CreateParams(var Params: TCreateParams);
15641564
Style := Style and not WS_BORDER;
15651565
ExStyle := ExStyle or WS_EX_CLIENTEDGE;
15661566
// avoid flicker while scrolling or resizing
1567-
if CheckWin32Version(5, 1) then
1567+
if not (csDesigning in ComponentState) and CheckWin32Version(5, 1) then
15681568
ExStyle := ExStyle or WS_EX_COMPOSITED;
15691569
end;
15701570

@@ -5129,7 +5129,9 @@ procedure TCustomSynEdit.WMCut(var Message: TMessage);
51295129
procedure TCustomSynEdit.WMDropFiles(var Msg: TMessage);
51305130
var
51315131
i, iNumberDropped: Integer;
5132+
{$IFNDEF UNICODE}
51325133
FileNameA: array[0..MAX_PATH - 1] of AnsiChar;
5134+
{$ENDIF}
51335135
FileNameW: array[0..MAX_PATH - 1] of WideChar;
51345136
Point: TPoint;
51355137
FilesList: TUnicodeStringList;

‎components/synedit/Source/SynEditKeyCmdEditor.pas

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ interface
5757
QSynEditKeyCmds,
5858
QSynEditMiscClasses,
5959
{$ELSE}
60+
{$IFDEF SYN_COMPILER_17_UP}
61+
UITypes,
62+
{$ENDIF}
6063
Windows,
6164
Messages,
6265
Graphics,

‎components/synedit/Source/SynEditKeyCmdsEditor.pas

+6
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ interface
5757
QButtons,
5858
QSynEditKeyCmds,
5959
{$ELSE}
60+
{$IFDEF SYN_COMPILER_15_UP}
61+
Types,
62+
{$ENDIF}
63+
{$IFDEF SYN_COMPILER_17_UP}
64+
UITypes,
65+
{$ENDIF}
6066
Windows,
6167
Messages,
6268
Graphics,

‎components/synedit/Source/SynEditOptionsDialog.pas

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ interface
6363
QSynEditMiscClasses,
6464
QSynEditKeyCmds,
6565
{$ELSE}
66+
{$IFDEF SYN_COMPILER_17_UP}
67+
Types,
68+
{$ENDIF}
6669
Windows,
6770
Messages,
6871
Graphics,

‎components/synedit/Source/SynEditPlugins.pas

+3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ interface
5252
QSynEditKeyCmds,
5353
QSynUnicode,
5454
{$ELSE}
55+
{$IFDEF SYN_COMPILER_17_UP}
56+
Types,
57+
{$ENDIF}
5558
Windows,
5659
Menus,
5760
SynEdit,

‎components/synedit/Source/SynEditPrint.pas

+3
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@ interface
107107
QSynEditHighlighter,
108108
QSynUnicode,
109109
{$ELSE}
110+
{$IFDEF SYN_COMPILER_17_UP}
111+
UITypes,
112+
{$ENDIF}
110113
Windows,
111114
Graphics,
112115
Printers,

‎components/synedit/Source/SynEditPrintHeaderFooter.pas

+3
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ interface
111111
QSynUnicode,
112112
QGraphics,
113113
{$ELSE}
114+
{$IFDEF SYN_COMPILER_17_UP}
115+
UITypes,
116+
{$ENDIF}
114117
Windows,
115118
SynEditPrintTypes,
116119
SynEditPrintMargins,

‎components/synedit/Source/SynEditPrintMarginsDialog.pas

+3
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ interface
6363
QSynEditPrintTypes,
6464
QSynEditPrintMargins,
6565
{$ELSE}
66+
{$IFDEF SYN_COMPILER_17_UP}
67+
UITypes,
68+
{$ENDIF}
6669
Windows,
6770
Graphics,
6871
Forms,

‎components/synedit/Source/SynEditPrintPreview.pas

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ interface
6565
{$IFDEF SYN_COMPILER_7}
6666
Themes,
6767
{$ENDIF}
68+
{$IFDEF SYN_COMPILER_17_UP}
69+
Types,
70+
{$ENDIF}
6871
Windows,
6972
Controls,
7073
Messages,

‎components/synedit/Source/SynHighlighterPython.pas

+1-2
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,13 @@ function TSynPythonSyn.GetKeywordIdentifiers: TUnicodeStringList;
224224
);
225225

226226
// List of non-keyword identifiers
227-
NONKEYWORDCOUNT = 66;
227+
NONKEYWORDCOUNT = 65;
228228
NONKEYWORDS: array [1..NONKEYWORDCOUNT] of UnicodeString =
229229
(
230230
'__future__',
231231
'__import__',
232232
'abs',
233233
'apply',
234-
'as',
235234
'buffer',
236235
'callable',
237236
'chr',

‎components/synedit/Source/SynHighlighterSQL.pas

+30-1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555

5656
interface
5757

58+
{$IFDEF SYN_COMPILER_12_UP}
59+
{$DEFINE USE_TABLE_DICTIONARY}
60+
{$ENDIF}
61+
5862
uses
5963
{$IFDEF SYN_CLX}
6064
Types,
@@ -71,6 +75,9 @@ interface
7175
SynHighlighterHashEntries,
7276
SynUnicode,
7377
{$ENDIF}
78+
{$IFDEF USE_TABLE_DICTIONARY}
79+
Generics.Collections,
80+
{$ENDIF}
7481
SysUtils,
7582
Classes;
7683

@@ -93,6 +100,9 @@ TSynSQLSyn = class(TSynCustomHighlighter)
93100
fKeywords: TSynHashEntryList;
94101
fProcNames: TUnicodeStrings;
95102
fTableNames: TUnicodeStrings;
103+
{$IFDEF USE_TABLE_DICTIONARY}
104+
fTableDict: TDictionary<string, Boolean>;
105+
{$ENDIF}
96106
fFunctionNames: TUniCodeStrings;
97107
fDialect: TSQLDialect;
98108
fCommentAttri: TSynHighlighterAttributes;
@@ -1238,7 +1248,12 @@ function TSynSQLSyn.IdentKind(MayBe: PWideChar): TtkTokenKind;
12381248
end;
12391249
Entry := Entry.Next;
12401250
end;
1241-
Result := tkIdentifier;
1251+
{$IFDEF USE_TABLE_DICTIONARY}
1252+
if fTableDict.ContainsKey(SynWideLowerCase(Copy(StrPas(fToIdent), 1, fStringLen))) then
1253+
Result := tkTableName
1254+
else
1255+
{$ENDIF}
1256+
Result := tkIdentifier;
12421257
end;
12431258

12441259
constructor TSynSQLSyn.Create(AOwner: TComponent);
@@ -1254,6 +1269,9 @@ constructor TSynSQLSyn.Create(AOwner: TComponent);
12541269

12551270
fTableNames := TUnicodeStringList.Create;
12561271
TUnicodeStringList(fTableNames).OnChange := TableNamesChanged;
1272+
{$IFDEF USE_TABLE_DICTIONARY}
1273+
fTableDict := TDictionary<string, Boolean>.Create;
1274+
{$ENDIF}
12571275

12581276
fFunctionNames := TunicodeStringList.Create;
12591277
TUnicodeStringList(fFunctionNames).OnChange := FunctionNamesChanged;
@@ -1317,6 +1335,9 @@ destructor TSynSQLSyn.Destroy;
13171335
fKeywords.Free;
13181336
fProcNames.Free;
13191337
fTableNames.Free;
1338+
{$IFDEF USE_TABLE_DICTIONARY}
1339+
fTableDict.Free;
1340+
{$ENDIF}
13201341
fFunctionNames.Free;
13211342
inherited Destroy;
13221343
end;
@@ -1895,7 +1916,12 @@ procedure TSynSQLSyn.PutTableNamesInKeywordList;
18951916
Entry := Entry.Next;
18961917
end;
18971918
if not Assigned(Entry) then
1919+
{$IFDEF USE_TABLE_DICTIONARY}
1920+
if not fTableDict.ContainsKey(SynWideLowerCase(fTableNames[i])) then
1921+
fTableDict.Add(SynWideLowerCase(fTableNames[i]), True);
1922+
{$ELSE}
18981923
DoAddKeyword(fTableNames[i], Ord(tkTableName));
1924+
{$ENDIF}
18991925
end;
19001926
end;
19011927

@@ -1946,6 +1972,9 @@ procedure TSynSQLSyn.InitializeKeywordLists;
19461972
{$ELSE}
19471973
fKeywords.Clear;
19481974
{$ENDIF}
1975+
{$IFDEF USE_TABLE_DICTIONARY}
1976+
fTableDict.Clear;
1977+
{$ENDIF}
19491978

19501979
for I := 0 to Ord(High(TtkTokenKind)) - 1 do
19511980
EnumerateKeywords(I, GetKeywords(I), IsIdentChar, DoAddKeyword);

‎components/synedit/Source/SynRegExpr.pas

+2
Original file line numberDiff line numberDiff line change
@@ -1296,7 +1296,9 @@ class function TRegExpr.ParseModifiersStr (const AModifiers : RegExprString;
12961296
begin
12971297
Result := true;
12981298
IsOn := true;
1299+
{$IFNDEF SYN_COMPILER_24_UP}
12991300
Mask := 0; // prevent compiler warning
1301+
{$ENDIF}
13001302
for i := 1 to length (AModifiers) do
13011303
if AModifiers [i] = '-'
13021304
then IsOn := false

‎components/synedit/Source/SynTextDrawer.pas

+3
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@
6868
interface
6969

7070
uses
71+
{$IFDEF SYN_COMPILER_17_UP}
72+
Types, UITypes,
73+
{$ENDIF}
7174
SynUnicode,
7275
SysUtils,
7376
Classes,

‎source/main.pas

+3-5
Original file line numberDiff line numberDiff line change
@@ -8068,14 +8068,12 @@ procedure TMainForm.ObjectnamesChanged(Connection: TDBConnection; Database: Stri
80688068
for Obj in DBObjects do begin
80698069
case Obj.NodeType of
80708070
lntTable, lntView: begin
8071-
// Limit slow highlighter to 1000 table names. See http://www.heidisql.com/forum.php?t=16307
8071+
// Slow highlighter enhanced by uschuster. See http://www.heidisql.com/forum.php?t=16307
80728072
// ... and here: https://github.com/SynEdit/SynEdit/issues/28
8073-
if TableNames.Count < 1000 then
8074-
TableNames.Add(Obj.Name);
8073+
TableNames.Add(Obj.Name);
80758074
end;
80768075
lntProcedure, lntFunction: begin
8077-
if ProcNames.Count < 1000 then
8078-
ProcNames.Add(Obj.Name);
8076+
ProcNames.Add(Obj.Name);
80798077
end;
80808078
end;
80818079
end;

0 commit comments

Comments
 (0)
Please sign in to comment.