From 56deb0bb3506268ab58fc8f0cf573cc7fe101a86 Mon Sep 17 00:00:00 2001 From: Andreas Louv Date: Tue, 14 Mar 2023 08:53:49 +0100 Subject: [PATCH] Add breaking Unicode character offset test The reason for this test to fail is that the language protocol requires offsets to be send based on UTF-16 strings, but currently they are computed based on another encoding. --- test/clangd_tests.vim | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/test/clangd_tests.vim b/test/clangd_tests.vim index 5800158..1ce4cd6 100644 --- a/test/clangd_tests.vim +++ b/test/clangd_tests.vim @@ -272,6 +272,40 @@ def g:Test_LspDiag() :%bw! enddef +# Test that the client have been able to configure the server to speak utf-32 +def g:Test_UnicodeColumnCalc() + :silent! edit Xtest.c + sleep 200m + var lines: list =<< trim END + int count; + int fn(int a) + { + int 😊😊😊😊; + 😊😊😊😊 = a; + + int b; + b = a; + return count + 1; + } + END + setline(1, lines) + :redraw! + + cursor(5, 1) # 😊😊😊😊 = a; + search('a') + assert_equal([], + execute('LspGotoDefinition')->split("\n")) + assert_equal([2, 12], [line('.'), col('.')]) + + cursor(8, 1) # b = a; + search('a') + assert_equal([], + execute('LspGotoDefinition')->split("\n")) + assert_equal([2, 12], [line('.'), col('.')]) + + bw! +enddef + # Test for multiple LSP diagnostics on the same line def g:Test_LspDiag_Multi() :silent! edit Xtest.c -- 2.48.1