1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-29 16:56:40 +03:00

GH-339 Migrate escaped file names

This commit is contained in:
Tae Won Ha 2017-01-06 08:38:13 +01:00
parent 49aa4a2440
commit e0ede2a02c
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44
3 changed files with 26 additions and 21 deletions

View File

@ -95,6 +95,8 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
case NeoVimAgentMsgIdSetBoolOption: return data_sync(data, outputCondition, neovim_set_bool_option);
case NeoVimAgentMsgIdGetEscapeFileNames: return data_sync(data, outputCondition, neovim_escaped_filenames);
default: break;
}
@ -283,17 +285,6 @@ static CFDataRef local_server_callback(CFMessagePortRef local, SInt32 msgid, CFD
return [NSData dataWithBytes:&dirty length:sizeof(bool)];
}
case NeoVimAgentMsgIdGetEscapeFileNames: {
NSArray <NSString *> *fileNames = [NSKeyedUnarchiver unarchiveObjectWithData:data];
NSMutableArray <NSString *> *result = [NSMutableArray new];
[fileNames enumerateObjectsUsingBlock:^(NSString* fileName, NSUInteger idx, BOOL *stop) {
[result addObject:server_escaped_filename(fileName)];
}];
return [NSKeyedArchiver archivedDataWithRootObject:result];
}
default:
return nil;
}

View File

@ -17,7 +17,6 @@ extern void server_delete(NSInteger count);
extern void server_resize(int width, int height);
extern void server_vim_input_marked_text(NSString *markedText);
extern bool server_has_dirty_docs();
extern NSString *server_escaped_filename(NSString *filename);
extern void server_quit();
extern void neovim_select_window(void **argv);
@ -26,3 +25,4 @@ extern void neovim_buffers(void **argv);
extern void neovim_vim_command_output(void **argv);
extern void neovim_set_bool_option(void **argv);
extern void neovim_get_bool_option(void **argv);
extern void neovim_escaped_filenames(void **argv);

View File

@ -685,15 +685,6 @@ bool server_has_dirty_docs() {
return false;
}
NSString *server_escaped_filename(NSString *filename) {
const char *file_system_rep = filename.fileSystemRepresentation;
char_u *escaped_filename = vim_strsave_fnameescape((char_u *) file_system_rep, 0);
NSString *result = [NSString stringWithCString:(const char *) escaped_filename encoding:NSUTF8StringEncoding];
xfree(escaped_filename);
return result;
}
static NeoVimBuffer *buffer_for(buf_T *buf) {
// To be sure...
@ -949,3 +940,26 @@ void neovim_get_bool_option(void **argv) {
return [NSKeyedArchiver archivedDataWithRootObject:@(result)];
});
}
static NSString *escaped_filename(NSString *filename) {
const char *file_system_rep = filename.fileSystemRepresentation;
char_u *escaped_filename = vim_strsave_fnameescape((char_u *) file_system_rep, 0);
NSString *result = [NSString stringWithCString:(const char *) escaped_filename encoding:NSUTF8StringEncoding];
xfree(escaped_filename);
return result;
}
void neovim_escaped_filenames(void **argv) {
work_and_write_data_sync(argv, ^NSData *(NSData *data) {
NSArray *fileNames = [NSKeyedUnarchiver unarchiveObjectWithData:data];
NSMutableArray *result = [NSMutableArray new];
[fileNames enumerateObjectsUsingBlock:^(NSString* fileName, NSUInteger idx, BOOL *stop) {
[result addObject:escaped_filename(fileName)];
}];
return [NSKeyedArchiver archivedDataWithRootObject:result];
});
}