mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-06 18:58:12 +02:00
SynEdit, IDE: Fix phys/logic char pos in autocomplete. Issue #0026038
git-svn-id: trunk@44755 -
This commit is contained in:
parent
f46dd07c9d
commit
845d3c0084
@ -373,7 +373,7 @@ begin
|
||||
AEditor.SelText := '';
|
||||
AEditor.SetTextBetweenPoints(p2, p2, s, [], scamEnd);
|
||||
if NewCaretPos then
|
||||
AEditor.CaretXY := p;
|
||||
AEditor.LogicalCaretXY := p;
|
||||
AEditor.EnsureCursorPosVisible;
|
||||
finally
|
||||
AEditor.EndUpdate;
|
||||
|
@ -74,7 +74,7 @@ type
|
||||
class function ConvertCommandToBase(Command: TSynEditorCommand): TSynEditorCommand;
|
||||
class function ConvertBaseToCommand(Command: TSynEditorCommand): TSynEditorCommand;
|
||||
|
||||
procedure SetTemplate(aTmpl: String; aCaretPos: TPoint); // Replaces current selection
|
||||
procedure SetTemplate(aTmpl: String; aLogCaretPos: TPoint); // Replaces current selection
|
||||
// Coords relativ to the template. base (1, 1)
|
||||
procedure AddEditCells(aCellList: TSynPluginSyncronizedEditList);
|
||||
|
||||
@ -296,7 +296,7 @@ begin
|
||||
Active := False;
|
||||
end;
|
||||
|
||||
procedure TSynPluginTemplateEdit.SetTemplate(aTmpl: String; aCaretPos: TPoint);
|
||||
procedure TSynPluginTemplateEdit.SetTemplate(aTmpl: String; aLogCaretPos: TPoint);
|
||||
var
|
||||
Temp: TStringList;
|
||||
CellStart, StartPos: TPoint;
|
||||
@ -383,8 +383,8 @@ begin
|
||||
Editor.SelText := aTmpl;
|
||||
with Cells.AddNew do begin
|
||||
Group := -2;
|
||||
LogStart := aCaretPos;
|
||||
LogEnd := aCaretPos;
|
||||
LogStart := aLogCaretPos;
|
||||
LogEnd := aLogCaretPos;
|
||||
end;
|
||||
if (Cells.Count > 1) then begin
|
||||
Active := True;
|
||||
@ -394,7 +394,7 @@ begin
|
||||
SetUndoStart;
|
||||
end
|
||||
else
|
||||
Editor.MoveCaretIgnoreEOL(aCaretPos);
|
||||
Editor.MoveCaretIgnoreEOL(Editor.LogicalToPhysicalPos(aLogCaretPos));
|
||||
end;
|
||||
|
||||
procedure TSynPluginTemplateEdit.AddEditCells(aCellList: TSynPluginSyncronizedEditList);
|
||||
|
@ -457,7 +457,7 @@ var
|
||||
p: TPoint;
|
||||
TokenStartX: LongInt;
|
||||
s: string;
|
||||
BaseIndent: Integer;
|
||||
BaseIndent, LogBaseIndent: Integer;
|
||||
i: Integer;
|
||||
j: LongInt;
|
||||
Pattern: String;
|
||||
@ -491,13 +491,14 @@ begin
|
||||
and ((BaseIndent>length(s)) or (s[BaseIndent] in [#9,' '])) do
|
||||
inc(BaseIndent);
|
||||
end;
|
||||
LogBaseIndent := BaseIndent - 1;
|
||||
BaseIndent:=AEditor.LogicalToPhysicalCol(s, p.y - 1, BaseIndent);// consider tabs
|
||||
dec(BaseIndent);
|
||||
end;
|
||||
|
||||
Parser.EnableMacros := Attributes.IndexOfName(CodeTemplateEnableMacros)>=0;
|
||||
Parser.KeepSubIndent := Attributes.IndexOfName(CodeTemplateKeepSubIndent)>=0;
|
||||
Parser.Indent := BaseIndent;
|
||||
Parser.Indent := LogBaseIndent;
|
||||
CodeToolBossOriginalIndent := CodeToolBoss.IndentSize;
|
||||
if Parser.KeepSubIndent then
|
||||
CodeToolBoss.IndentSize := BaseIndent // Use additional indentation
|
||||
@ -522,11 +523,12 @@ begin
|
||||
AEditor.BlockEnd := p;
|
||||
|
||||
// New Caret
|
||||
p := Parser.DestCaret;
|
||||
p := Parser.DestCaret; // Logical
|
||||
if p.y >= 0 then begin
|
||||
if p.y = 1 then
|
||||
p.x := p.x + TokenStartX - 1;
|
||||
p.y := p.y + AEditor.BlockBegin.y - 1; // Todo: logicalToPhysical
|
||||
p.y := p.y + AEditor.BlockBegin.y - 1;
|
||||
// p must be logical, until template text is inserted
|
||||
end;
|
||||
|
||||
// delete double end separator (e.g. avoid creating two semicolons 'begin end;;')
|
||||
@ -560,7 +562,7 @@ begin
|
||||
// replace the selected text and position the caret
|
||||
AEditor.SetTextBetweenPoints(AEditor.BlockBegin, AEditor.BlockEnd, Parser.DestTemplate, [], scamEnd);
|
||||
if p.y > 0 then
|
||||
AEditor.MoveCaretIgnoreEOL(p);
|
||||
AEditor.MoveCaretIgnoreEOL(AEditor.LogicalToPhysicalPos(p));
|
||||
end;
|
||||
finally
|
||||
AEditor.EndUpdate;
|
||||
|
Loading…
Reference in New Issue
Block a user