mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 17:00:57 +02:00
SynEdit: Fix for smart unindent. (if no shorter line is present above)
git-svn-id: trunk@48547 -
This commit is contained in:
parent
06241f9a2d
commit
a8782bed08
@ -1526,7 +1526,7 @@ begin
|
|||||||
Dec(BackCounter);
|
Dec(BackCounter);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if SpaceCount2 = SpaceCount1 then
|
if SpaceCount2 >= SpaceCount1 then
|
||||||
SpaceCount2 := 0;
|
SpaceCount2 := 0;
|
||||||
// remove visible spaces
|
// remove visible spaces
|
||||||
LogSpacePos := FCurrentLines.PhysicalToLogicalCol(Line, ACaret.LinePos-1, SpaceCount2 + 1);
|
LogSpacePos := FCurrentLines.PhysicalToLogicalCol(Line, ACaret.LinePos-1, SpaceCount2 + 1);
|
||||||
|
@ -71,6 +71,7 @@ type
|
|||||||
procedure IndentCallBack;
|
procedure IndentCallBack;
|
||||||
|
|
||||||
procedure IndentPasComment;
|
procedure IndentPasComment;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -79,8 +80,8 @@ implementation
|
|||||||
{ TTestSynBeautifier }
|
{ TTestSynBeautifier }
|
||||||
|
|
||||||
var SkipGroupUndo: Boolean;
|
var SkipGroupUndo: Boolean;
|
||||||
procedure TTestSynBeautifier.TestRedoUndo(Name: String; Text: Array of String;
|
procedure TTestSynBeautifier.TestRedoUndo(Name: String; Text: array of String; X, Y: Integer;
|
||||||
X, Y: Integer; Data: array of const; SelX: Integer = -1; SelY: Integer = -1);
|
Data: array of const; SelX: Integer; SelY: Integer);
|
||||||
|
|
||||||
function data2txt(n: Integer): String;
|
function data2txt(n: Integer): String;
|
||||||
begin
|
begin
|
||||||
@ -519,6 +520,18 @@ procedure TTestSynBeautifier.DefaultUnIndent;
|
|||||||
begin
|
begin
|
||||||
Result := LinesToText(LinesReplace(TestText, rpl))
|
Result := LinesToText(LinesReplace(TestText, rpl))
|
||||||
end;
|
end;
|
||||||
|
function TestText2: TStringArray;
|
||||||
|
begin
|
||||||
|
SetLength(Result, 4);
|
||||||
|
Result[0] := ' a;';
|
||||||
|
Result[1] := ' b';
|
||||||
|
Result[2] := ' ';
|
||||||
|
Result[3] := '';
|
||||||
|
end;
|
||||||
|
function ExpText2(rpl: array of const): String;
|
||||||
|
begin
|
||||||
|
Result := LinesToText(LinesReplace(TestText2, rpl))
|
||||||
|
end;
|
||||||
begin
|
begin
|
||||||
SkipGroupUndo := False;
|
SkipGroupUndo := False;
|
||||||
ReCreateEdit;
|
ReCreateEdit;
|
||||||
@ -592,6 +605,14 @@ begin
|
|||||||
SynEdit.Options2 := SynEdit.Options2 - [eoPersistentBlock];
|
SynEdit.Options2 := SynEdit.Options2 - [eoPersistentBlock];
|
||||||
|
|
||||||
|
|
||||||
|
BaseTestName := 'UnIndent, with 1st line indended most';
|
||||||
|
SynEdit.Options := SynEdit.Options - [eoTrimTrailingSpaces{, eoScrollPastEol}];
|
||||||
|
SynEdit.Options2 := SynEdit.Options2 - [eoPersistentBlock];
|
||||||
|
TestRedoUndo('extra indent on first', TestText2, 7,3,
|
||||||
|
[ VK_BACK, 5,3, ExpText2([ 3, ' ']),
|
||||||
|
VK_BACK, 1,3, ExpText2([ 3, ''])
|
||||||
|
] );
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TTestSynBeautifier.GetIndentCallBack(Sender: TObject; Editor: TObject;
|
function TTestSynBeautifier.GetIndentCallBack(Sender: TObject; Editor: TObject;
|
||||||
|
Loading…
Reference in New Issue
Block a user