]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Add breaking Unicode character offset test
authorAndreas Louv <andreas@louv.dk>
Tue, 14 Mar 2023 07:53:49 +0000 (08:53 +0100)
committerAndreas Louv <andreas@louv.dk>
Fri, 31 Mar 2023 17:50:05 +0000 (19:50 +0200)
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

index 5800158bbc72fb75bf44cb42b61bf410883c5c48..1ce4cd612f26f8a79ef15b89f2cc57f5e0d54d11 100644 (file)
@@ -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<string> =<< 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