diff --git a/applications/lazedit/editorpagecontrol.pp b/applications/lazedit/editorpagecontrol.pp index 5faf7a7e5..58a2cb958 100644 --- a/applications/lazedit/editorpagecontrol.pp +++ b/applications/lazedit/editorpagecontrol.pp @@ -99,6 +99,7 @@ type procedure LoadFromFileUtf8(const Utf8Fn: String; const AsTemplate: Boolean = False); procedure SaveToFileAnsi(const AnsiFn: String); procedure SaveToFileUtf8(const Utf8Fn: String); + function IsUnused: Boolean; procedure SetHighlighterByFileType(const AFileType: TEditorFileType; const Permanent: Boolean = False); procedure MarkSelection(const Pre, Post: String); @@ -690,6 +691,12 @@ begin end; end; +function TEditor.IsUnused: Boolean; +begin + //debugln('TEditor.IsUnused: Modified = ',DbgS(Modified),', FFileName = "',FFileName,'", Length(Text) = ',DbgS(Length(Text))); + Result := (not Modified) and (FFileName = EmptyStr) and (Length(Text) = 0); +end; + procedure TEditor.SetHighlighterByFileType(const AFileType: TEditorFileType; const Permanent: Boolean = False); begin if Assigned(FEditorPageControl) then diff --git a/applications/lazedit/main.pp b/applications/lazedit/main.pp index 4f88d510e..29ecb69f0 100644 --- a/applications/lazedit/main.pp +++ b/applications/lazedit/main.pp @@ -2048,7 +2048,11 @@ begin Exit; end; end;} - Ed := NoteBook.AddPage; + //If available, open new file in unused open Tab (if that is the current active one) + if (Assigned(NoteBook.CurrentEditor) and (NoteBook.CurrentEditor.IsUnused)) then + Ed := NoteBook.CurrentEditor + else + Ed := NoteBook.AddPage; if Assigned(Ed) then begin try