mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-28 11:35:35 +03:00
GH-512 Let neovim exit in mch_exit()
- NeoVimServer exited due to stopping of the CFRunLoop. Maybe this caused the crash???
This commit is contained in:
parent
0c20cebfe6
commit
924b45bb1a
@ -56,7 +56,6 @@ typedef NS_ENUM(NSInteger, NeoVimAgentMsgId) {
|
||||
NeoVimAgentMsgIdSelectWindow,
|
||||
NeoVimAgentMsgIdScroll,
|
||||
NeoVimAgentMsgIdCursorGoto,
|
||||
NeoVimAgentMsgIdQuit,
|
||||
|
||||
NeoVimAgentMsgIdGetDirtyDocs,
|
||||
NeoVimAgentMsgIdGetPwd,
|
||||
|
@ -31,7 +31,6 @@ static const double qTimeout = 10;
|
||||
|
||||
- (NSArray<NSString *> *)nvimArgs;
|
||||
- (NSCondition *)outputCondition;
|
||||
- (void)handleQuitMsg;
|
||||
|
||||
@end
|
||||
|
||||
@ -67,10 +66,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
return NULL;
|
||||
}
|
||||
|
||||
case NeoVimAgentMsgIdQuit:
|
||||
[neoVimServer handleQuitMsg];
|
||||
return NULL;
|
||||
|
||||
case NeoVimAgentMsgIdCommandOutput: return data_sync(data, outputCondition, neovim_vim_command_output);
|
||||
|
||||
case NeoVimAgentMsgIdSelectWindow: return data_sync(data, outputCondition, neovim_select_window);
|
||||
@ -78,7 +73,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
case NeoVimAgentMsgIdScroll: return data_sync(data, outputCondition, neovim_scroll);
|
||||
|
||||
case NeoVimAgentMsgIdGetTabs: return data_sync(data, outputCondition, neovim_tabs);
|
||||
|
||||
|
||||
case NeoVimAgentMsgIdGetBuffers: return data_sync(data, outputCondition, neovim_buffers);
|
||||
|
||||
case NeoVimAgentMsgIdGetBoolOption: return data_sync(data, outputCondition, neovim_get_bool_option);
|
||||
@ -98,7 +93,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
case NeoVimAgentMsgIdInputMarked: return data_sync(data, outputCondition, neovim_vim_input_marked_text);
|
||||
|
||||
case NeoVimAgentMsgIdDelete: return data_sync(data, outputCondition, neovim_delete);
|
||||
|
||||
|
||||
case NeoVimAgentMsgIdGetPwd: return data_sync(data, outputCondition, neovim_pwd);
|
||||
|
||||
case NeoVimAgentMsgIdCursorGoto: return data_sync(data, outputCondition, neovim_cursor_goto);
|
||||
@ -242,13 +237,4 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
#endif
|
||||
}
|
||||
|
||||
- (void)quit {
|
||||
quit_neovim();
|
||||
}
|
||||
|
||||
- (void)handleQuitMsg {
|
||||
// exit() after returning the response such that the agent can get the response and so does not log a warning.
|
||||
[self performSelector:@selector(quit) onThread:_localServerThread withObject:nil waitUntilDone:NO];
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -14,7 +14,7 @@
|
||||
NeoVimServer *_neovim_server;
|
||||
CFRunLoopRef _mainRunLoop;
|
||||
|
||||
void observe_parent_termination() {
|
||||
static void observe_parent_termination() {
|
||||
pid_t parentPID = getppid();
|
||||
|
||||
dispatch_queue_t queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
||||
@ -29,7 +29,7 @@ void observe_parent_termination() {
|
||||
|
||||
dispatch_source_set_event_handler(source, ^{
|
||||
WLOG("Exiting neovim server due to parent termination.");
|
||||
quit_neovim();
|
||||
CFRunLoopStop(_mainRunLoop);
|
||||
dispatch_source_cancel(source);
|
||||
});
|
||||
|
||||
|
@ -647,11 +647,6 @@ void start_neovim(NSInteger width, NSInteger height, NSArray<NSString *> *args)
|
||||
[data release];
|
||||
}
|
||||
|
||||
void quit_neovim() {
|
||||
DLOG("NeoVimServer exiting...");
|
||||
CFRunLoopStop(_mainRunLoop);
|
||||
}
|
||||
|
||||
#pragma mark Functions for neovim's main loop
|
||||
|
||||
typedef NSData *(^work_block)(NSData *);
|
||||
@ -1109,4 +1104,4 @@ void neovim_debug1(void **argv) {
|
||||
|
||||
return nil;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -123,10 +123,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local __unused, SInt32 m
|
||||
- (void)quit {
|
||||
OSAtomicOr32Barrier(1, &_neoVimIsQuitting);
|
||||
|
||||
// Wait till we get the response from the server.
|
||||
// If we don't wait here, then the NSTask.terminate msg below could get caught by neovim which causes a warning log.
|
||||
[self sendMessageWithId:NeoVimAgentMsgIdQuit data:nil expectsReply:YES];
|
||||
|
||||
if (CFMessagePortIsValid(_remoteServerPort)) {
|
||||
CFMessagePortInvalidate(_remoteServerPort);
|
||||
}
|
||||
@ -141,10 +137,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local __unused, SInt32 m
|
||||
|
||||
CFRunLoopStop(_localServerRunLoop);
|
||||
[_localServerThread cancel];
|
||||
|
||||
// Just to be sure...
|
||||
[_neoVimServerTask interrupt];
|
||||
[_neoVimServerTask terminate];
|
||||
}
|
||||
|
||||
- (void)launchNeoVimUsingLoginShell {
|
||||
@ -405,7 +397,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local __unused, SInt32 m
|
||||
}
|
||||
|
||||
- (NSData *)sendMessageWithId:(NeoVimAgentMsgId)msgid data:(NSData *)data expectsReply:(bool)expectsReply {
|
||||
if (_neoVimIsQuitting == 1 && msgid != NeoVimAgentMsgIdQuit) {
|
||||
if (_neoVimIsQuitting == 1) {
|
||||
// This happens often, e.g. when exiting full screen by closing all buffers. We try to resize the window after
|
||||
// the message port has been closed. This is a quick-and-dirty fix.
|
||||
// TODO: Fix for real...
|
||||
@ -425,7 +417,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local __unused, SInt32 m
|
||||
_remoteServerPort, msgid, (__bridge CFDataRef) data, qTimeout, qTimeout, replyMode, &responseData
|
||||
);
|
||||
|
||||
if (msgid == NeoVimAgentMsgIdQuit || _neoVimIsQuitting == 1) {
|
||||
if (_neoVimIsQuitting == 1) {
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
2
neovim
2
neovim
@ -1 +1 @@
|
||||
Subproject commit 10311cc8424df2307b1385251a0d3990b49351a9
|
||||
Subproject commit 4e22de4ec62102cd08cd1164133edd474881c817
|
Loading…
Reference in New Issue
Block a user