Browse Source

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

Margers 11 months ago
parent
commit
31bc7c4054
4 changed files with 9 additions and 8 deletions
  1. 1 1
      packages/ide/fpcompil.pas
  2. 1 1
      packages/ide/fptools.pas
  3. 1 1
      packages/ide/fpviews.pas
  4. 6 5
      packages/ide/wcedit.pas

+ 1 - 1
packages/ide/fpcompil.pas

@@ -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

+ 1 - 1
packages/ide/fptools.pas

@@ -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

+ 1 - 1
packages/ide/fpviews.pas

@@ -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;
 

+ 6 - 5
packages/ide/wcedit.pas

@@ -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;