ZSaberLv0 / ZFVimIM

vim输入法 / Vim Input Method by pure vim script, support: user word, dynamic word priority, cloud db files
204 stars 14 forks source link

repoPath 和 dbFile 拼接成路径的方式不符合直觉 #26

Closed jdhao closed 3 years ago

jdhao commented 3 years ago

目前的配置,repoPath 最后的 / 不能少,少了 /, 如果 dbFile 的路径前面没有 /,那么拼接成完整路径的时候就出错,这太反直觉了。例如如下的配置是错的:

    call ZFVimIM_cloudRegister({
                \   'mode': 'local',
                \   'dbId' : db['dbId'],
                \   'repoPath' : expand('~/Projects/trial_error'),
                \   'dbFile' : 'pinyin_huge.txt',
                \   'dbCountFile': 'pinyin_huge_count.txt'
                \ })

就是因为 trial_error 后面 或者 pinyin_huge.txt 前面少了反斜杠。

理想的方式,repoPath 指定的路径,加不加反斜杠均可,dbFile 的路径最好前面不加反斜杠,加了反斜杠很违和,好像代表的是 Linux 根目录下的某个目录一样。

这种字符串拼接的活,应该用 os.path.join() 类似的方法去完成,手工来搞,太容易出问题了。

ZSaberLv0 commented 3 years ago

已添加容错处理