1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-11-24 03:25:03 +03:00

Revert "GH-376 Compute tabs in the main loop"

This reverts commit 5fbc773584.
This commit is contained in:
Tae Won Ha 2017-01-04 17:38:28 +01:00
parent b03393a3e0
commit 279a768bf7
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
4 changed files with 8 additions and 32 deletions

View File

@ -255,10 +255,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
}
case NeoVimAgentMsgIdGetTabs: {
NSUInteger responseId = response_id_from_data(data);
server_tabs(responseId);
return nil;
return [NSKeyedArchiver archivedDataWithRootObject:server_tabs()];
}
case NeoVimAgentMsgIdGetBoolOption: {

View File

@ -20,7 +20,7 @@ extern void server_vim_input_marked_text(NSString *markedText);
extern bool server_has_dirty_docs();
extern NSString *server_escaped_filename(NSString *filename);
extern NSArray *server_buffers();
extern void server_tabs(NSUInteger responseId);
extern NSArray *server_tabs();
extern void server_get_bool_option(NSUInteger responseId, NSString *option);
extern void server_set_bool_option(NSUInteger responseId, NSString *option, bool value);
extern void server_select_win(int window_handle);

View File

@ -792,10 +792,7 @@ NSArray *server_buffers() {
return result;
}
static void neovim_tabs(void **argv) {
NSUInteger *values = (NSUInteger *) argv[0];
NSUInteger responseId = values[0];
NSArray *server_tabs() {
NSMutableArray *tabs = [[NSMutableArray new] autorelease];
FOR_ALL_TABS(t) {
NSMutableArray *windows = [NSMutableArray new];
@ -818,22 +815,7 @@ static void neovim_tabs(void **argv) {
[tab release];
}
NSData *resultData = [NSKeyedArchiver archivedDataWithRootObject:tabs];
NSData *data = data_with_response_id_prefix(responseId, resultData);
[_neovim_server sendMessageWithId:NeoVimServerMsgIdSyncResult data:data];
free(values); // malloc'ed in loop_schedule(&main_loop, ...) (in _queue) somewhere
}
void server_tabs(NSUInteger responseId) {
queue(^{
NSUInteger *values = malloc(sizeof(NSUInteger));
values[0] = responseId;
// free release in neovim_command
loop_schedule(&main_loop, event_create(1, neovim_tabs, 1, values));
});
return tabs;
}
void server_select_win(int window_handle) {

View File

@ -347,16 +347,13 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
}
- (NSArray<NeoVimWindow *> *)tabs {
NSUInteger reqId = [self nextRequestResponseId];
NSData *data = [NSData dataWithBytes:&reqId length:sizeof(NSUInteger)];
[self sendMessageWithId:NeoVimAgentMsgIdGetTabs data:data expectsReply:NO];
NSData *responseData = [self responseByWaitingForId:reqId];
if (responseData == nil) {
NSData *response = [self sendMessageWithId:NeoVimAgentMsgIdGetTabs data:nil expectsReply:YES];
if (response == nil) {
log4Warn("The response for the msg %lu was nil.", NeoVimAgentMsgIdGetTabs);
return @[];
}
return [NSKeyedUnarchiver unarchiveObjectWithData:responseData];
return [NSKeyedUnarchiver unarchiveObjectWithData:response];
}
- (void)runLocalServer {