mirror of
https://github.com/qvacua/vimr.git
synced 2024-12-28 08:13:17 +03:00
GH-392 Synchronize all nvim_... calls
This commit is contained in:
parent
580eba9332
commit
e815bc6641
@ -34,11 +34,6 @@ static const double qTimeout = 10;
|
||||
|
||||
@end
|
||||
|
||||
static CFDataRef null_data_async(CFDataRef data, argv_callback cb) {
|
||||
loop_schedule(&main_loop, event_create(1, cb, 1, data));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static CFDataRef data_sync(CFDataRef data, NSCondition *condition, argv_callback cb) {
|
||||
DataWrapper *wrapper = [[DataWrapper alloc] init];
|
||||
NSDate *deadline = [[NSDate date] dateByAddingTimeInterval:qTimeout];
|
||||
@ -75,7 +70,7 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
|
||||
case NeoVimAgentMsgIdCommandOutput: return data_sync(data, outputCondition, neovim_vim_command_output);
|
||||
|
||||
case NeoVimAgentMsgIdSelectWindow: return null_data_async(data, neovim_select_window);
|
||||
case NeoVimAgentMsgIdSelectWindow: return data_sync (data, outputCondition, neovim_select_window);
|
||||
|
||||
case NeoVimAgentMsgIdGetTabs: return data_sync(data, outputCondition, neovim_tabs);
|
||||
|
||||
@ -89,17 +84,17 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
|
||||
|
||||
case NeoVimAgentMsgIdGetDirtyDocs: return data_sync(data, outputCondition, neovim_has_dirty_docs);
|
||||
|
||||
case NeoVimAgentMsgIdResize: return null_data_async(data, neovim_resize);
|
||||
case NeoVimAgentMsgIdResize: return data_sync (data, outputCondition, neovim_resize);
|
||||
|
||||
case NeoVimAgentMsgIdCommand: return null_data_async(data, neovim_vim_command);
|
||||
case NeoVimAgentMsgIdCommand: return data_sync (data, outputCondition, neovim_vim_command);
|
||||
|
||||
case NeoVimAgentMsgIdInput: return null_data_async(data, neovim_vim_input);
|
||||
case NeoVimAgentMsgIdInput: return data_sync (data, outputCondition, neovim_vim_input);
|
||||
|
||||
case NeoVimAgentMsgIdInputMarked: return null_data_async(data, neovim_vim_input_marked_text);
|
||||
case NeoVimAgentMsgIdInputMarked: return data_sync (data, outputCondition, neovim_vim_input_marked_text);
|
||||
|
||||
case NeoVimAgentMsgIdDelete: return null_data_async(data, neovim_delete);
|
||||
case NeoVimAgentMsgIdDelete: return data_sync (data, outputCondition, neovim_delete);
|
||||
|
||||
case NeoVimAgentMsgIdCursorGoto: return null_data_async(data, neovim_cursor_goto);
|
||||
case NeoVimAgentMsgIdCursorGoto: return data_sync (data, outputCondition, neovim_cursor_goto);
|
||||
|
||||
default: return NULL;
|
||||
|
||||
|
@ -540,13 +540,13 @@ static void work_and_write_data_sync(void **argv, work_block block) {
|
||||
}
|
||||
}
|
||||
|
||||
static void work_async(void **argv, work_block block) {
|
||||
@autoreleasepool {
|
||||
NSData *data = argv[0];
|
||||
block(data);
|
||||
[data release]; // retained in local_server_callback
|
||||
}
|
||||
}
|
||||
//static void work_async(void **argv, work_block block) {
|
||||
// @autoreleasepool {
|
||||
// NSData *data = argv[0];
|
||||
// block(data);
|
||||
// [data release]; // retained in local_server_callback
|
||||
// }
|
||||
//}
|
||||
|
||||
static NSString *escaped_filename(NSString *filename) {
|
||||
const char *file_system_rep = filename.fileSystemRepresentation;
|
||||
@ -585,7 +585,7 @@ static NeoVimBuffer *buffer_for(buf_T *buf) {
|
||||
}
|
||||
|
||||
void neovim_select_window(void **argv) {
|
||||
work_async(argv, ^NSData *(NSData *data) {
|
||||
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
|
||||
int handle = ((int *) data.bytes)[0];
|
||||
|
||||
FOR_ALL_TAB_WINDOWS(tab, win) {
|
||||
@ -754,7 +754,7 @@ void neovim_has_dirty_docs(void **argv) {
|
||||
}
|
||||
|
||||
void neovim_resize(void **argv) {
|
||||
work_async(argv, ^NSData *(NSData *data) {
|
||||
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
|
||||
const int *values = data.bytes;
|
||||
int width = values[0];
|
||||
int height = values[1];
|
||||
@ -767,7 +767,7 @@ void neovim_resize(void **argv) {
|
||||
}
|
||||
|
||||
void neovim_vim_command(void **argv) {
|
||||
work_async(argv, ^NSData *(NSData *data) {
|
||||
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
|
||||
NSString *input = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
|
||||
|
||||
Error err = ERROR_INIT;
|
||||
@ -784,7 +784,7 @@ void neovim_vim_command(void **argv) {
|
||||
}
|
||||
|
||||
void neovim_vim_input(void **argv) {
|
||||
work_async(argv, ^NSData *(NSData *data) {
|
||||
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
|
||||
NSString *input = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
|
||||
|
||||
if (_marked_text == nil) {
|
||||
@ -818,7 +818,7 @@ void neovim_vim_input(void **argv) {
|
||||
}
|
||||
|
||||
void neovim_vim_input_marked_text(void **argv) {
|
||||
work_async(argv, ^NSData *(NSData *data) {
|
||||
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
|
||||
NSString *markedText = [[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding] autorelease];
|
||||
|
||||
if (_marked_text == nil) {
|
||||
@ -838,7 +838,7 @@ void neovim_vim_input_marked_text(void **argv) {
|
||||
}
|
||||
|
||||
void neovim_delete(void **argv) {
|
||||
work_async(argv, ^NSData *(NSData *data) {
|
||||
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
|
||||
const NSInteger *values = data.bytes;
|
||||
NSInteger count = values[0];
|
||||
|
||||
@ -871,7 +871,7 @@ void neovim_delete(void **argv) {
|
||||
}
|
||||
|
||||
void neovim_cursor_goto(void **argv) {
|
||||
work_async(argv, ^NSData *(NSData *data) {
|
||||
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
|
||||
const int *values = data.bytes;
|
||||
|
||||
Array position = ARRAY_DICT_INIT;
|
||||
|
Loading…
Reference in New Issue
Block a user