Skip to content

Commit b4f29a5

Browse files
committed
Bug fix: Properly escape Vim script strings in omnicomplete.lua
1 parent 2f29afe commit b4f29a5

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

autoload/xolox/lua.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
" Vim auto-load script
22
" Author: Peter Odding <peter@peterodding.com>
3-
" Last Change: April 30, 2013
3+
" Last Change: May 12, 2013
44
" URL: http://peterodding.com/code/vim/lua-ftplugin
55

6-
let g:xolox#lua#version = '0.7.3'
6+
let g:xolox#lua#version = '0.7.4'
77
let s:miscdir = expand('<sfile>:p:h:h:h') . '/misc/lua-ftplugin'
88
let s:omnicomplete_script = s:miscdir . '/omnicomplete.lua'
99
let s:globals_script = s:miscdir . '/globals.lua'

misc/lua-ftplugin/omnicomplete.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ local function addmatch(word, kind, desc)
2929
if not desc then
3030
print(string.format("{'word':'%s','kind':'%s'}", word, kind))
3131
else
32-
print(string.format("{'word':'%s','kind':'%s','menu':'%s'}", word, kind, (desc:gsub('\n', ' '))))
32+
-- Make sure we generate valid Vim script expressions (this is probably
33+
-- still not right).
34+
desc = desc:gsub('\n', '\\n')
35+
:gsub('\r', '\\r')
36+
:gsub("'", "''")
37+
print(string.format("{'word':'%s','kind':'%s','menu':'%s'}", word, kind, desc))
3338
end
3439
end
3540

0 commit comments

Comments
 (0)