diff options
| author | Sean Dewar <seandewar@users.noreply.github.com> | 2021-04-19 19:57:19 +0100 |
|---|---|---|
| committer | Sean Dewar <seandewar@users.noreply.github.com> | 2021-04-20 10:12:02 +0100 |
| commit | 6a0b8cbd81f81957a415cf03415bf2bffc18b56e (patch) | |
| tree | 0c469e0ab5c4d16e88e2bb4645a9bea2b499d542 /src/nvim/testdir | |
| parent | 1d72b6e4cd5807d27acce9b6f8b6d22176e50951 (diff) | |
| download | rneovim-6a0b8cbd81f81957a415cf03415bf2bffc18b56e.tar.gz rneovim-6a0b8cbd81f81957a415cf03415bf2bffc18b56e.tar.bz2 rneovim-6a0b8cbd81f81957a415cf03415bf2bffc18b56e.zip | |
vim-patch:8.2.1933: cannot sort using locale ordering
Problem: Cannot sort using locale ordering.
Solution: Add a flag for :sort and sort() to use the locale. (Dominique
Pellé, closes vim/vim#7237)
https://github.com/vim/vim/commit/55e29611d20bca14fa5efc61385bc8a6b7acd9e2
Diffstat (limited to 'src/nvim/testdir')
| -rw-r--r-- | src/nvim/testdir/test_sort.vim | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_sort.vim b/src/nvim/testdir/test_sort.vim index 8287a761c6..278cbef01e 100644 --- a/src/nvim/testdir/test_sort.vim +++ b/src/nvim/testdir/test_sort.vim @@ -13,6 +13,25 @@ func Test_sort_strings() " numbers compared as strings call assert_equal([1, 2, 3], sort([3, 2, 1])) call assert_equal([13, 28, 3], sort([3, 28, 13])) + + call assert_equal(['A', 'O', 'P', 'a', 'o', 'p', 'Ä', 'Ô', 'ä', 'ô', 'œ', 'œ'], + \ sort(['A', 'O', 'P', 'a', 'o', 'p', 'Ä', 'Ô', 'ä', 'ô', 'œ', 'œ'])) + + call assert_equal(['A', 'a', 'o', 'O', 'p', 'P', 'Ä', 'Ô', 'ä', 'ô', 'œ', 'œ'], + \ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'i')) + + let lc = execute('language collate') + " With the following locales, the accentuated letters are ordered + " similarly to the non-accentuated letters... + if lc =~? '"\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8"' + call assert_equal(['a', 'A', 'ä', 'Ä', 'o', 'O', 'ô', 'Ô', 'œ', 'œ', 'p', 'P'], + \ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l')) + " ... whereas with a Swedish locale, the accentuated letters are ordered + " after Z. + elseif lc =~? '"sv.*utf-\?8"' + call assert_equal(['a', 'A', 'o', 'O', 'p', 'P', 'ä', 'Ä', 'œ', 'œ', 'ô', 'Ô'], + \ sort(['A', 'a', 'o', 'O', 'œ', 'œ', 'p', 'P', 'Ä', 'ä', 'ô', 'Ô'], 'l')) + endif endfunc func Test_sort_numeric() @@ -1223,6 +1242,58 @@ func Test_sort_cmd() \ }, \ ] + " With the following locales, the accentuated letters are ordered + " similarly to the non-accentuated letters... + let lc = execute('language collate') + if lc =~? '"\(en\|es\|de\|fr\|it\|nl\).*\.utf-\?8"' + let tests += [ + \ { + \ 'name' : 'sort with locale', + \ 'cmd' : '%sort l', + \ 'input' : [ + \ 'A', + \ 'E', + \ 'O', + \ 'À', + \ 'È', + \ 'É', + \ 'Ô', + \ 'Œ', + \ 'Z', + \ 'a', + \ 'e', + \ 'o', + \ 'à', + \ 'è', + \ 'é', + \ 'ô', + \ 'œ', + \ 'z' + \ ], + \ 'expected' : [ + \ 'a', + \ 'A', + \ 'à', + \ 'À', + \ 'e', + \ 'E', + \ 'é', + \ 'É', + \ 'è', + \ 'È', + \ 'o', + \ 'O', + \ 'ô', + \ 'Ô', + \ 'œ', + \ 'Œ', + \ 'z', + \ 'Z' + \ ] + \ }, + \ ] + endif + for t in tests enew! call append(0, t.input) |