Skip to content

Commit 4f1696a

Browse files
committed
fix: finding matches after composite Unicode characters
Using `strcharpart` incidentally fixes #108.
1 parent 7eeeb3f commit 4f1696a

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

fnl/leap/util.fnl

+7-5
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,14 @@
5050
(if opts.case_sensitive ch* (vim.fn.tolower ch*)))
5151

5252

53-
; Note: on 0.10+ we could replace this with vim.fn.strcharpart (with
54-
; `skipcc`).
5553
(fn get-char-from [str idx] ; zero-based (<- vim.fn.charidx())
56-
(local nr (vim.fn.strgetchar str idx))
57-
(if (= nr -1) ""
58-
(vim.fn.nr2char nr)))
54+
(if (= (vim.fn.has "nvim-0.10") 1)
55+
; `skipcc` parameter (essential) is only available from 0.10.
56+
(vim.fn.strcharpart str idx 1 1)
57+
; `strgetchar` has a bug with composite unicode chars (#108).
58+
(let [nr (vim.fn.strgetchar str idx)]
59+
(if (= nr -1) ""
60+
(vim.fn.nr2char nr)))))
5961

6062

6163
; Input

lua/leap/util.lua

+19-15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)