Skip to content

Commit

Permalink
Merge pull request #5274 from rstudio/bugfix/save-all/satellites
Browse files Browse the repository at this point in the history
Make Save All command work across satellites
  • Loading branch information
jmcphers committed Aug 21, 2019
2 parents d4ee623 + 20ed30c commit b86e763
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,8 @@ well as menu structures (for main menu and popup menus).
label="Save All Source Documents"
menuLabel="Sa_ve All"
buttonLabel=""
desc="Save all open documents"/>
desc="Save all open documents"
windowMode="main"/>

<cmd id="saveSourceDocWithEncoding"
label="Save Current Document with Encoding..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2214,6 +2214,7 @@ private void cpsExecuteForEachEditor(ArrayList<EditingTarget> editors,
@Handler
public void onSaveAllSourceDocs()
{
// Save all documents in the main window
cpsExecuteForEachEditor(editors_, new CPSEditingTargetCommand()
{
@Override
Expand All @@ -2229,6 +2230,9 @@ public void execute(EditingTarget target, Command continuation)
}
}
});

// Save all documents in satellite windows
windowManager_.saveUnsavedDocuments(null, null);
}


Expand Down Expand Up @@ -3923,7 +3927,15 @@ private void manageSaveCommands()


private void manageSaveAllCommand()
{
{
// if source windows are open, managing state of the command becomes
// complicated, so leave it enabled
if (windowManager_.areSourceWindowsOpen())
{
commands_.saveAllSourceDocs().setEnabled(true);
return;
}

// if one document is dirty then we are enabled
for (EditingTarget target : editors_)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ public boolean isSourceWindowOpen(String windowId)
return sourceWindows_.containsKey(windowId);
}

public boolean areSourceWindowsOpen()
{
return !sourceWindows_.isEmpty();
}

public String getWindowIdOfDocPath(String path)
{
SourceDocument doc = getDocFromPath(path);
Expand Down Expand Up @@ -379,7 +384,6 @@ public void saveWithPrompt(UnsavedChangesItem item, Command onCompleted)
public void saveUnsavedDocuments(final Set<String> ids,
final Command onCompleted)
{

doForAllSourceWindows(new SourceWindowCommand()
{
@Override
Expand Down

0 comments on commit b86e763

Please sign in to comment.