diff dialog, add button to reload with history destruction

This commit is contained in:
Basile Burg 2020-04-25 01:59:48 +02:00
parent 50b653bf34
commit 318f2419e7
4 changed files with 86 additions and 54 deletions

View File

@ -2,8 +2,10 @@
## Enhancements ## Enhancements
- Dlang highlighter: added suport for HEREDOC strings literal of type `q"()"` `q"[]"`, `q"<>"` and `q"{}"`. "Custom" HEREDOC strings literal wont be handled as they might be removed as per DIP 1026. - D highlighter: added suport for HEREDOC strings literal of type `q"()"` `q"[]"`, `q"<>"` and `q"{}"`. Support for HEREDOC strings literal based on a custom identifier wont be added as they might be removed as per DIP 1026.
- Docking: added a dialog to remind that docking is locked in certain scenarios. (#30) - Docking: added a dialog to remind that docking is locked in certain scenarios. (#30)
- Editor: set the option to detect the indentation mode on by default, to prevent mixed indentation style.
- Editor: a fourth button in the diff dialog allows to reload but without preserving the undo history, which is better to navigate using _go to next changed area_ and _go to prev changed area_.
- Search Replace: the result of _FindAll_ when the string to seach is a regular expression are highlighted. (#14) - Search Replace: the result of _FindAll_ when the string to seach is a regular expression are highlighted. (#14)
- TODO list: a new option, _disableIfMoreFilesThan_, allows to disable auto refreshing of the list could be slow when the current project is huge. - TODO list: a new option, _disableIfMoreFilesThan_, allows to disable auto refreshing of the list could be slow when the current project is huge.

View File

@ -1,16 +1,16 @@
object DiffViewer: TDiffViewer object DiffViewer: TDiffViewer
Left = 1004 Left = 1004
Height = 441 Height = 468
Top = 279 Top = 279
Width = 516 Width = 578
Caption = 'External file modification' Caption = 'External file modification'
ClientHeight = 441 ClientHeight = 468
ClientWidth = 516 ClientWidth = 578
inline editor: TSynEdit inline editor: TSynEdit
Left = 4 Left = 4
Height = 387 Height = 414
Top = 15 Top = 15
Width = 508 Width = 570
Align = alClient Align = alClient
BorderSpacing.Around = 4 BorderSpacing.Around = 4
Font.Height = -13 Font.Height = -13
@ -112,17 +112,17 @@ object DiffViewer: TDiffViewer
object Panel1: TPanel object Panel1: TPanel
Left = 4 Left = 4
Height = 31 Height = 31
Top = 406 Top = 433
Width = 508 Width = 570
Align = alBottom Align = alBottom
AutoSize = True AutoSize = True
BorderSpacing.Around = 4 BorderSpacing.Around = 4
BevelOuter = bvLowered BevelOuter = bvLowered
ClientHeight = 31 ClientHeight = 31
ClientWidth = 508 ClientWidth = 570
TabOrder = 1 TabOrder = 1
object btnIgnore: TBitBtn object btnIgnore: TBitBtn
Left = 106 Left = 68
Height = 27 Height = 27
Hint = 'Don''t show this dialog until more modifications are detected' Hint = 'Don''t show this dialog until more modifications are detected'
Top = 2 Top = 2
@ -138,55 +138,71 @@ object DiffViewer: TDiffViewer
TabOrder = 0 TabOrder = 0
end end
object btnAccept: TBitBtn object btnAccept: TBitBtn
Left = 382 Left = 347
Height = 27 Height = 27
Hint = 'Load the new version' Hint = 'Load the external version but still allow to undo'
Top = 2 Top = 2
Width = 124 Width = 55
Align = alRight Align = alRight
AutoSize = True AutoSize = True
BorderSpacing.Left = 2 BorderSpacing.Left = 2
BorderSpacing.Around = 1 BorderSpacing.Around = 1
Caption = 'Load new version' Caption = 'Reload'
ModalResult = 1 ModalResult = 1
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 2 TabOrder = 2
end end
object btnCancel: TBitBtn object btnCancel: TBitBtn
Left = 287 Left = 249
Height = 27 Height = 27
Hint = 'Don''t reload the modifications for now' Hint = 'Don''t reload the external version this time'
Top = 2 Top = 2
Width = 92 Width = 95
Align = alRight Align = alRight
AutoSize = True AutoSize = True
BorderSpacing.Left = 2 BorderSpacing.Left = 2
BorderSpacing.Around = 1 BorderSpacing.Around = 1
Caption = 'Keep current' Caption = 'Keep for now'
ModalResult = 2 ModalResult = 2
ParentShowHint = False ParentShowHint = False
ShowHint = True ShowHint = True
TabOrder = 1 TabOrder = 1
end end
object btnAccept1: TBitBtn
Left = 405
Height = 27
Hint = 'Load the external version and reset the history of changes'
Top = 2
Width = 163
Align = alRight
AutoSize = True
BorderSpacing.Left = 2
BorderSpacing.Around = 1
Caption = 'Reload and reset undos'
ModalResult = 8
ParentShowHint = False
ShowHint = True
TabOrder = 3
end
end end
object Panel2: TPanel object Panel2: TPanel
Left = 4 Left = 4
Height = 7 Height = 7
Top = 4 Top = 4
Width = 508 Width = 570
Align = alTop Align = alTop
AutoSize = True AutoSize = True
BorderSpacing.Around = 4 BorderSpacing.Around = 4
BevelOuter = bvLowered BevelOuter = bvLowered
ClientHeight = 7 ClientHeight = 7
ClientWidth = 508 ClientWidth = 570
TabOrder = 2 TabOrder = 2
object lbl: TLabel object lbl: TLabel
Left = 3 Left = 3
Height = 1 Height = 1
Top = 3 Top = 3
Width = 502 Width = 564
Align = alClient Align = alClient
Alignment = taCenter Alignment = taCenter
BorderSpacing.Around = 2 BorderSpacing.Around = 2

View File

@ -10,7 +10,11 @@ uses
u_common, StdCtrls, ExtCtrls, Buttons; u_common, StdCtrls, ExtCtrls, Buttons;
type type
{ TDiffViewer }
TDiffViewer = class(TForm) TDiffViewer = class(TForm)
btnAccept1: TBitBtn;
btnIgnore: TBitBtn; btnIgnore: TBitBtn;
btnAccept: TBitBtn; btnAccept: TBitBtn;
btnCancel: TBitBtn; btnCancel: TBitBtn;

View File

@ -3432,7 +3432,7 @@ var
newMd5 : TMDDigest; newMd5 : TMDDigest;
curMd5 : TMDDigest; curMd5 : TMDDigest;
str : TStringList; str : TStringList;
txt: string; newTxt : string;
begin begin
if fDiffDialogWillClose or fDisableFileDateCheck then if fDiffDialogWillClose or fDisableFileDateCheck then
exit; exit;
@ -3450,35 +3450,45 @@ begin
str := TStringList.Create; str := TStringList.Create;
try try
str.LoadFromFile(fFilename); str.LoadFromFile(fFilename);
txt := str.strictText; newTxt := str.strictText;
newMd5 := MD5String(txt); finally
txt := lines.strictText; str.Free;
curMd5 := MD5String(txt); end;
newMd5 := MD5String(newTxt);
curMd5 := MD5String(lines.strictText);
if not MDMatch(curMd5, newMd5) then if not MDMatch(curMd5, newMd5) then
begin begin
lines.SaveToFile(tempFilename); lines.SaveToFile(tempFilename);
fDiffDialogWillClose := true; fDiffDialogWillClose := true;
With TDiffViewer.construct(self, fTempFileName, fFilename) do with TDiffViewer.construct(self, fTempFileName, fFilename) do
try try
mr := ShowModal; mr := ShowModal;
case mr of case mr of
mrOK: mrOK:
begin begin
replaceUndoableContent(str.strictText); replaceUndoableContent(newTxt);
fModified := false; fModified := false;
fFileDate := newDate; fFileDate := newDate;
end; end;
mrIgnore: fFileDate := newDate; mrAll:
mrCancel:; begin
fModified := false;
text := newTxt;
fFileDate := newDate;
end;
mrIgnore:
begin
fFileDate := newDate;
end;
mrCancel:
begin
end;
end; end;
finally finally
free; free;
fDiffDialogWillClose := false; fDiffDialogWillClose := false;
end; end;
end; end;
finally
str.Free;
end;
end end
else fFileDate := newDate; else fFileDate := newDate;
end; end;