On exit ask for changes to save if one file open in two windows.

This commit is contained in:
Margers 2024-09-04 08:34:51 +00:00
parent 9146eaf083
commit 31bc7c4054
4 changed files with 9 additions and 8 deletions

View File

@ -839,7 +839,7 @@ begin
FileName:=P^.Editor^.FileName;
if FileName='' then
begin
P^.Editor^.SaveAsk(true);
P^.Editor^.SaveAsk(cmValid,true);
FileName:=P^.Editor^.FileName;
end;
end

View File

@ -1305,7 +1305,7 @@ begin
begin
I:=I+ReplacePart(LastWordStart,I-1,'')-1;
if W<>nil then
if W^.Editor^.SaveAsk(true)=false then
if W^.Editor^.SaveAsk(cmValid,true)=false then
Err:=-1;
end;
end else

View File

@ -1892,7 +1892,7 @@ begin
if OK and ({(Command=cmClose) or already handled in TFileEditor.Valid PM }
(Command=cmAskSaveAll)) then
if IsClipboard=false then
OK:=SaveAsk(false);
OK:=SaveAsk(Command,false);
Valid:=OK;
end;

View File

@ -234,7 +234,7 @@ type
PScrollBar; AIndicator: PIndicator; ACore: PCodeEditorCore; const AFileName: string);
function Save: Boolean; virtual;
function SaveAs: Boolean; virtual;
function SaveAsk(Force: boolean): Boolean; virtual;
function SaveAsk(Command: Word; Force: boolean): boolean; virtual;
function LoadFile: boolean; virtual;
function ReloadFile: boolean; virtual;
function SaveFile: boolean; virtual;
@ -265,7 +265,7 @@ implementation
uses Dos,
WConsts,
FVConsts,
FVConsts,FPConst,
App,WViews;
{$ifndef NOOBJREG}
@ -1931,7 +1931,7 @@ begin
end;
end;
function TFileEditor.SaveAsk(Force: boolean): boolean;
function TFileEditor.SaveAsk(Command: Word; Force: boolean): boolean;
var OK: boolean;
D: Sw_integer;
begin
@ -1946,7 +1946,8 @@ begin
begin
OK:=(GetModified=false);
if (OK=false) and (Core^.GetBindingCount>1) then
OK:=true;
if (command<>cmAskSaveAll) or (Core^.GetBindingIndex(PCustomCodeEditor(@self))<>0) then
OK:=true;
if OK=false then
begin
if FileName = '' then D := edSaveUntitled else D := edSaveModify;
@ -2002,7 +2003,7 @@ begin
OK:=inherited Valid(Command);
if OK and (Command=cmClose) then
if IsClipboard=false then
OK:=SaveAsk(false);
OK:=SaveAsk(Command,false);
Valid:=OK;
end;