diff --git a/SwiftNeoVim/NeoVimAgent.m b/SwiftNeoVim/NeoVimAgent.m index 004dd56b..479f44f5 100644 --- a/SwiftNeoVim/NeoVimAgent.m +++ b/SwiftNeoVim/NeoVimAgent.m @@ -395,7 +395,9 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD if (responseCode != kCFMessagePortSuccess) { log_cfmachport_error(responseCode, msgid, data); - [_bridge ipcBecameInvalid]; + [_bridge ipcBecameInvalid: + [NSString stringWithFormat:@"Reason: sendMsg failed for %d with %d", msgid, responseCode] + ]; return nil; } diff --git a/SwiftNeoVim/NeoVimUiBridgeProtocol.h b/SwiftNeoVim/NeoVimUiBridgeProtocol.h index 915a494c..e4c5d363 100644 --- a/SwiftNeoVim/NeoVimUiBridgeProtocol.h +++ b/SwiftNeoVim/NeoVimUiBridgeProtocol.h @@ -123,7 +123,7 @@ NS_ASSUME_NONNULL_BEGIN */ - (void)stop; -- (void)ipcBecameInvalid; +- (void)ipcBecameInvalid:(NSString *)reason; @end diff --git a/SwiftNeoVim/NeoVimView.swift b/SwiftNeoVim/NeoVimView.swift index 046b15b5..8cb03c81 100644 --- a/SwiftNeoVim/NeoVimView.swift +++ b/SwiftNeoVim/NeoVimView.swift @@ -89,7 +89,7 @@ public class NeoVimView: NSView, NeoVimUiBridgeProtocol, NSUserInterfaceValidati public var cwd: URL { get { guard let output = self.agent.vimCommandOutput("silent pwd") else { - self.ipcBecameInvalid() + self.ipcBecameInvalid("Reason: 'silent pwd' failed") return URL(fileURLWithPath: NSHomeDirectory()) } @@ -730,7 +730,7 @@ extension NeoVimView { } guard let curPasteMode = self.agent.boolOption("paste") else { - self.ipcBecameInvalid() + self.ipcBecameInvalid("Reason: 'set paste' failed") return } @@ -1438,10 +1438,10 @@ extension NeoVimView { } } - public func ipcBecameInvalid() { + public func ipcBecameInvalid(_ reason: String) { NSLog("ERROR \(#function): force-quitting") DispatchUtils.gui { - self.delegate?.ipcBecameInvalid() + self.delegate?.ipcBecameInvalid(reason: reason) self.agent.quit() } } diff --git a/SwiftNeoVim/NeoVimViewDelegate.swift b/SwiftNeoVim/NeoVimViewDelegate.swift index f8af4f2a..b455862a 100644 --- a/SwiftNeoVim/NeoVimViewDelegate.swift +++ b/SwiftNeoVim/NeoVimViewDelegate.swift @@ -14,5 +14,5 @@ public protocol NeoVimViewDelegate: class { func cwdChanged() func bufferListChanged() - func ipcBecameInvalid() + func ipcBecameInvalid(reason: String) } diff --git a/VimR/MainWindowComponent.swift b/VimR/MainWindowComponent.swift index 2d246a23..bbc466f3 100644 --- a/VimR/MainWindowComponent.swift +++ b/VimR/MainWindowComponent.swift @@ -483,11 +483,12 @@ extension MainWindowComponent { self.publish(event: MainWindowAction.changeBufferList(mainWindow: self, buffers: buffers)) } - func ipcBecameInvalid() { + func ipcBecameInvalid(reason: String) { let alert = NSAlert() alert.addButton(withTitle: "Close") alert.messageText = "Sorry, an error occurred." - alert.informativeText = "VimR encountered an error from which it cannot recover. This window will now close." + alert.informativeText = "VimR encountered an error from which it cannot recover. This window will now close.\n" + + reason alert.alertStyle = .critical alert.beginSheetModal(for: self.window) { [weak self] response in self?.windowController.close()