mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	Merge pull request #14563 from mjlbach/fix_intelephense_langserver
lsp: handle case where CompletionItem.insertTextFormat is nil
This commit is contained in:
		| @@ -566,13 +566,15 @@ end | |||||||
| --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion | --@see https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_completion | ||||||
| local function get_completion_word(item) | local function get_completion_word(item) | ||||||
|   if item.textEdit ~= nil and item.textEdit.newText ~= nil and item.textEdit.newText ~= "" then |   if item.textEdit ~= nil and item.textEdit.newText ~= nil and item.textEdit.newText ~= "" then | ||||||
|     if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText" then |     local insert_text_format = protocol.InsertTextFormat[item.insertTextFormat] | ||||||
|  |     if insert_text_format == "PlainText" or insert_text_format == nil then | ||||||
|       return item.textEdit.newText |       return item.textEdit.newText | ||||||
|     else |     else | ||||||
|       return M.parse_snippet(item.textEdit.newText) |       return M.parse_snippet(item.textEdit.newText) | ||||||
|     end |     end | ||||||
|   elseif item.insertText ~= nil and item.insertText ~= "" then |   elseif item.insertText ~= nil and item.insertText ~= "" then | ||||||
|     if protocol.InsertTextFormat[item.insertTextFormat] == "PlainText" then |     local insert_text_format = protocol.InsertTextFormat[item.insertTextFormat] | ||||||
|  |     if insert_text_format == "PlainText" or insert_text_format == nil then | ||||||
|       return item.insertText |       return item.insertText | ||||||
|     else |     else | ||||||
|       return M.parse_snippet(item.insertText) |       return M.parse_snippet(item.insertText) | ||||||
|   | |||||||
| @@ -1393,10 +1393,10 @@ describe('LSP', function() | |||||||
|         { label='foocar', sortText="e", insertText='foodar', textEdit={newText='foobar'} }, |         { label='foocar', sortText="e", insertText='foodar', textEdit={newText='foobar'} }, | ||||||
|         { label='foocar', sortText="f", textEdit={newText='foobar'} }, |         { label='foocar', sortText="f", textEdit={newText='foobar'} }, | ||||||
|         -- real-world snippet text |         -- real-world snippet text | ||||||
|         { label='foocar', sortText="g", insertText='foodar', textEdit={newText='foobar(${1:place holder}, ${2:more ...holder{\\}})'} }, |         { label='foocar', sortText="g", insertText='foodar', insertTextFormat=2, textEdit={newText='foobar(${1:place holder}, ${2:more ...holder{\\}})'} }, | ||||||
|         { label='foocar', sortText="h", insertText='foodar(${1:var1} typ1, ${2:var2} *typ2) {$0\\}', textEdit={} }, |         { label='foocar', sortText="h", insertText='foodar(${1:var1} typ1, ${2:var2} *typ2) {$0\\}', insertTextFormat=2, textEdit={} }, | ||||||
|         -- nested snippet tokens |         -- nested snippet tokens | ||||||
|         { label='foocar', sortText="i", insertText='foodar(${1:var1 ${2|typ2,typ3|} ${3:tail}}) {$0\\}', textEdit={} }, |         { label='foocar', sortText="i", insertText='foodar(${1:var1 ${2|typ2,typ3|} ${3:tail}}) {$0\\}', insertTextFormat=2, textEdit={} }, | ||||||
|         -- plain text |         -- plain text | ||||||
|         { label='foocar', sortText="j", insertText='foodar(${1:var1})', insertTextFormat=1, textEdit={} }, |         { label='foocar', sortText="j", insertText='foodar(${1:var1})', insertTextFormat=1, textEdit={} }, | ||||||
|       } |       } | ||||||
| @@ -1408,9 +1408,9 @@ describe('LSP', function() | |||||||
|         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="d", insertText='foobar', textEdit={} } } } } }, |         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="d", insertText='foobar', textEdit={} } } } } }, | ||||||
|         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="e", insertText='foodar', textEdit={newText='foobar'} } } } } }, |         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="e", insertText='foodar', textEdit={newText='foobar'} } } } } }, | ||||||
|         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="f", textEdit={newText='foobar'} } } } } }, |         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="f", textEdit={newText='foobar'} } } } } }, | ||||||
|         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar(place holder, more ...holder{})', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="g", insertText='foodar', textEdit={newText='foobar(${1:place holder}, ${2:more ...holder{\\}})'} } } } } }, |         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foobar(place holder, more ...holder{})', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="g", insertText='foodar', insertTextFormat=2, textEdit={newText='foobar(${1:place holder}, ${2:more ...holder{\\}})'} } } } } }, | ||||||
|         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foodar(var1 typ1, var2 *typ2) {}', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="h", insertText='foodar(${1:var1} typ1, ${2:var2} *typ2) {$0\\}', textEdit={} } } } } }, |         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foodar(var1 typ1, var2 *typ2) {}', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="h", insertText='foodar(${1:var1} typ1, ${2:var2} *typ2) {$0\\}', insertTextFormat=2, textEdit={} } } } } }, | ||||||
|         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foodar(var1 typ2,typ3 tail) {}', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="i", insertText='foodar(${1:var1 ${2|typ2,typ3|} ${3:tail}}) {$0\\}', textEdit={} } } } } }, |         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foodar(var1 typ2,typ3 tail) {}', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="i", insertText='foodar(${1:var1 ${2|typ2,typ3|} ${3:tail}}) {$0\\}', insertTextFormat=2, textEdit={} } } } } }, | ||||||
|         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foodar(${1:var1})', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="j", insertText='foodar(${1:var1})', insertTextFormat=1, textEdit={} } } } } }, |         { abbr = 'foocar', dup = 1, empty = 1, icase = 1, info = ' ', kind = 'Unknown', menu = '', word = 'foodar(${1:var1})', user_data = { nvim = { lsp = { completion_item = { label='foocar', sortText="j", insertText='foodar(${1:var1})', insertTextFormat=1, textEdit={} } } } } }, | ||||||
|       } |       } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Michael Lingelbach
					Michael Lingelbach