mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-25 23:02:35 +03:00
GH-360 Show reason when the IPC got invalid
This commit is contained in:
parent
16c35ba682
commit
a4fbdfff39
@ -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;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
*/
|
||||
- (void)stop;
|
||||
|
||||
- (void)ipcBecameInvalid;
|
||||
- (void)ipcBecameInvalid:(NSString *)reason;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
@ -14,5 +14,5 @@ public protocol NeoVimViewDelegate: class {
|
||||
func cwdChanged()
|
||||
func bufferListChanged()
|
||||
|
||||
func ipcBecameInvalid()
|
||||
func ipcBecameInvalid(reason: String)
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user