Skip to content

Commit

Permalink
save all changed documents before build (NM-1293)
Browse files Browse the repository at this point in the history
  • Loading branch information
aesilevich committed Dec 12, 2023
1 parent e0b625f commit 1365109
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Nimble/Sources/NimbleWorkbench.swift
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,8 @@ extension NimbleWorkbench {
currentDocument?.saveAs(sender)
}

@IBAction func saveAll(_ sender: Any?) {
documents.forEach{$0.save(sender)}
@IBAction public func saveAll(_ sender: Any?) {
documents.forEach{($0 as! NimbleDocument).saveIfChanged(sender)}
}

@IBAction func close(_ sender: Any?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public class BuildSystemsManager: WorkbenchTaskObserver, WorkbenchObserver, Proj
public func build(variant: Variant, terminationHandler: TerminationHandler? = nil) {
// saving current document
// TODO: do we really need it here?
variant.target.workbench.currentDocument?.save(nil)
variant.target.workbench.saveAll(nil)

startBuildTask(variant: variant,
actionName: "Build",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ open class NimbleDocument: NSDocument {
savePanel.isExtensionHidden = false
return true
}

// Saves document if it was changed
public func saveIfChanged(_ sender: Any?) {
if self.isDocumentEdited {
self.save(sender)
}
}

open override func save(to url: URL,
ofType typeName: String,
Expand Down
2 changes: 2 additions & 0 deletions Packages/NimbleCore/Sources/NimbleCore/Workbench.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public protocol Workbench: AnyObject {

@discardableResult
func close(_ doc: Document) -> Bool

func saveAll(_ sender: Any?)

func createConsole(title: String, show: Bool, startReading: Bool) -> Console?

Expand Down

0 comments on commit 1365109

Please sign in to comment.