mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-07-29 07:57:01 +02:00
IDE: update name of editor-macro in source-editor when renaming in macro list. Issue #41699
This commit is contained in:
parent
a9114f590f
commit
ad7c2022b0
@ -957,8 +957,12 @@ end;
|
|||||||
|
|
||||||
procedure TCodeCache.OnBufferSetFileName(Sender: TCodeBuffer;
|
procedure TCodeCache.OnBufferSetFileName(Sender: TCodeBuffer;
|
||||||
const OldFilename: string);
|
const OldFilename: string);
|
||||||
|
var
|
||||||
|
OldFile: TCodeBuffer;
|
||||||
begin
|
begin
|
||||||
FItems.Delete(FItems.Find(FindFile(OldFilename)));
|
OldFile := FindFile(OldFilename);
|
||||||
|
if OldFile <> nil then
|
||||||
|
FItems.Delete(FItems.Find(OldFile));
|
||||||
if FindFile(Sender.Filename)=nil then
|
if FindFile(Sender.Filename)=nil then
|
||||||
FItems.Add(Sender);
|
FItems.Add(Sender);
|
||||||
end;
|
end;
|
||||||
|
@ -41,7 +41,7 @@ uses
|
|||||||
LazIDEIntf, IDEDialogs,
|
LazIDEIntf, IDEDialogs,
|
||||||
// IDE
|
// IDE
|
||||||
LazarusIDEStrConsts, ProjectDefs, LazConf, Project, KeyMapping,
|
LazarusIDEStrConsts, ProjectDefs, LazConf, Project, KeyMapping,
|
||||||
KeyMapShortCutDlg, MainIntf, ToolBarIntf;
|
KeyMapShortCutDlg, MainIntf, ToolBarIntf, ProjectIntf;
|
||||||
|
|
||||||
type
|
type
|
||||||
TSynEditorMacro = class(TSynMacroRecorder)
|
TSynEditorMacro = class(TSynMacroRecorder)
|
||||||
@ -299,6 +299,8 @@ procedure SaveGlobalInfo;
|
|||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
|
uses SourceFileManager;
|
||||||
|
|
||||||
{$R *.lfm}
|
{$R *.lfm}
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -349,6 +351,11 @@ begin
|
|||||||
else if AName = 'Ide' then Result := EditorMacroListGlob;
|
else if AName = 'Ide' then Result := EditorMacroListGlob;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function InternalFilenameForMacro(AnOwnerList: TEditorMacroList; AMacro: TEditorMacro): string;
|
||||||
|
begin
|
||||||
|
Result := EditorMacroVirtualDrive+MacroListToName(AnOwnerList)+'|'+AMacro.MacroName;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure DoEditorMacroStateChanged;
|
procedure DoEditorMacroStateChanged;
|
||||||
begin
|
begin
|
||||||
if EditorMacroForRecording= nil then exit;
|
if EditorMacroForRecording= nil then exit;
|
||||||
@ -1099,6 +1106,8 @@ procedure TMacroListViewer.btnRenameClick(Sender: TObject);
|
|||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
M: TEditorMacro;
|
M: TEditorMacro;
|
||||||
|
UnitInfo: TUnitInfo;
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
if lbMacroView.ItemIndex < 0 then exit;
|
if lbMacroView.ItemIndex < 0 then exit;
|
||||||
M := CurrentEditorMacroList.Macros[lbMacroView.ItemIndex];
|
M := CurrentEditorMacroList.Macros[lbMacroView.ItemIndex];
|
||||||
@ -1115,8 +1124,14 @@ begin
|
|||||||
s := '';
|
s := '';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
if s <> '' then
|
if s <> '' then begin
|
||||||
|
UnitInfo := Project1.UnitInfoWithFilename(InternalFilenameForMacro(CurrentEditorMacroList, M), [pfsfOnlyVirtualFiles]);
|
||||||
M.MacroName := s;
|
M.MacroName := s;
|
||||||
|
if UnitInfo <> nil then begin
|
||||||
|
UnitInfo.Filename := InternalFilenameForMacro(CurrentEditorMacroList, M);
|
||||||
|
UpdateSourceNames;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
UpdateDisplay;
|
UpdateDisplay;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1180,7 +1195,7 @@ begin
|
|||||||
M := CurrentEditorMacroList.Macros[lbMacroView.ItemIndex];
|
M := CurrentEditorMacroList.Macros[lbMacroView.ItemIndex];
|
||||||
if M = nil then exit;
|
if M = nil then exit;
|
||||||
LazarusIDE.DoOpenEditorFile(
|
LazarusIDE.DoOpenEditorFile(
|
||||||
EditorMacroVirtualDrive+MacroListToName(CurrentEditorMacroList)+'|'+M.MacroName,
|
InternalFilenameForMacro(CurrentEditorMacroList, M),
|
||||||
-1, -1, [ofVirtualFile, ofInternalFile]);
|
-1, -1, [ofVirtualFile, ofInternalFile]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1231,7 +1246,7 @@ begin
|
|||||||
CurrentEditorMacroList.Add(M);
|
CurrentEditorMacroList.Add(M);
|
||||||
Assert(not FIsPlaying, 'TMacroListViewer.btnAddEditNewClick: IsPlaying');
|
Assert(not FIsPlaying, 'TMacroListViewer.btnAddEditNewClick: IsPlaying');
|
||||||
LazarusIDE.DoOpenEditorFile(
|
LazarusIDE.DoOpenEditorFile(
|
||||||
EditorMacroVirtualDrive+MacroListToName(CurrentEditorMacroList)+'|'+M.MacroName,
|
InternalFilenameForMacro(CurrentEditorMacroList, M),
|
||||||
-1, -1, [ofVirtualFile, ofInternalFile]);
|
-1, -1, [ofVirtualFile, ofInternalFile]);
|
||||||
|
|
||||||
UpdateDisplay;
|
UpdateDisplay;
|
||||||
@ -1351,26 +1366,42 @@ end;
|
|||||||
procedure TMacroListViewer.tbMoveIDEClick(Sender: TObject);
|
procedure TMacroListViewer.tbMoveIDEClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
M: TEditorMacro;
|
||||||
|
UnitInfo: TUnitInfo;
|
||||||
begin
|
begin
|
||||||
if (lbMacroView.ItemIndex < 0) or (CurrentEditorMacroList = EditorMacroListGlob) then exit;
|
if (lbMacroView.ItemIndex < 0) or (CurrentEditorMacroList = EditorMacroListGlob) then exit;
|
||||||
i := lbMacroView.ItemIndex;
|
i := lbMacroView.ItemIndex;
|
||||||
EditorMacroListGlob.Add(CurrentEditorMacroList.Macros[i]);
|
M := CurrentEditorMacroList.Macros[i];
|
||||||
|
UnitInfo := Project1.UnitInfoWithFilename(InternalFilenameForMacro(CurrentEditorMacroList, M), [pfsfOnlyVirtualFiles]);
|
||||||
|
EditorMacroListGlob.Add(M);
|
||||||
CurrentEditorMacroList.Delete(i);
|
CurrentEditorMacroList.Delete(i);
|
||||||
if CurrentEditorMacroList = EditorMacroListProj then Project1.Modified := True;
|
if CurrentEditorMacroList = EditorMacroListProj then Project1.Modified := True;
|
||||||
MainIDEInterface.SaveEnvironment(False);
|
MainIDEInterface.SaveEnvironment(False);
|
||||||
|
if UnitInfo <> nil then begin
|
||||||
|
UnitInfo.Filename := InternalFilenameForMacro(EditorMacroListGlob, M);
|
||||||
|
UpdateSourceNames;
|
||||||
|
end;
|
||||||
UpdateDisplay;
|
UpdateDisplay;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMacroListViewer.tbMoveProjectClick(Sender: TObject);
|
procedure TMacroListViewer.tbMoveProjectClick(Sender: TObject);
|
||||||
var
|
var
|
||||||
i: Integer;
|
i: Integer;
|
||||||
|
M: TEditorMacro;
|
||||||
|
UnitInfo: TUnitInfo;
|
||||||
begin
|
begin
|
||||||
if (lbMacroView.ItemIndex < 0) or (CurrentEditorMacroList = EditorMacroListProj) then exit;
|
if (lbMacroView.ItemIndex < 0) or (CurrentEditorMacroList = EditorMacroListProj) then exit;
|
||||||
i := lbMacroView.ItemIndex;
|
i := lbMacroView.ItemIndex;
|
||||||
EditorMacroListProj.Add(CurrentEditorMacroList.Macros[i]);
|
M := CurrentEditorMacroList.Macros[i];
|
||||||
|
UnitInfo := Project1.UnitInfoWithFilename(InternalFilenameForMacro(CurrentEditorMacroList, M), [pfsfOnlyVirtualFiles]);
|
||||||
|
EditorMacroListProj.Add(M);
|
||||||
CurrentEditorMacroList.Delete(i);
|
CurrentEditorMacroList.Delete(i);
|
||||||
Project1.Modified := True;
|
Project1.Modified := True;
|
||||||
if CurrentEditorMacroList = EditorMacroListGlob then MainIDEInterface.SaveEnvironment(False);
|
if CurrentEditorMacroList = EditorMacroListGlob then MainIDEInterface.SaveEnvironment(False);
|
||||||
|
if UnitInfo <> nil then begin
|
||||||
|
UnitInfo.Filename := InternalFilenameForMacro(EditorMacroListProj, M);
|
||||||
|
UpdateSourceNames;
|
||||||
|
end;
|
||||||
UpdateDisplay;
|
UpdateDisplay;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2081,8 +2081,14 @@ end;
|
|||||||
|
|
||||||
procedure TUnitInfo.SetFilename(const AValue: string);
|
procedure TUnitInfo.SetFilename(const AValue: string);
|
||||||
begin
|
begin
|
||||||
if fSource<>nil then
|
if fSource<>nil then begin
|
||||||
LazTracer.RaiseGDBException('TUnitInfo.SetFilename Source<>nil')
|
if InternalFile then begin
|
||||||
|
fSource.Filename := AValue;
|
||||||
|
fFileName:=AValue
|
||||||
|
end
|
||||||
|
else
|
||||||
|
LazTracer.RaiseGDBException('TUnitInfo.SetFilename Source<>nil');
|
||||||
|
end
|
||||||
else
|
else
|
||||||
SetInternalFilename(AValue);
|
SetInternalFilename(AValue);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user