Fix: Handle multibyte chars properly in get_cells (#1298) (fixes #1297)

Previously vimwiki#tbl#get_cells() would act on `line` as a normal
string (i.e. using `[idx]` and strpart()). This breaks when the column
separator (s:s_rep() or rxTableSep) is a multibyte character like the
vertical box drawing character │. In that case the separator is never
found and only one empty cell is returned. This also affects
vimwiki#tbl#format() which in turn clears the whole table each time the
insert mode is left.

Fix this issue by initially splitting the line into a list of the
characters. Getting the elements with `[idx]` now returns each character
instead of a byte. In addition len() is used in place of strlen() as
well as slicing together with join() instead of strpart().

Fixes: #1297 ("Table formatting breaks on multibyte separator")
This commit is contained in:
Julian Prein
2023-06-23 01:10:54 +02:00
committed by GitHub
parent bc3bc208d7
commit c5b7f7e76f
2 changed files with 9 additions and 6 deletions
+2
View File
@@ -4002,9 +4002,11 @@ Contributors and their Github usernames in roughly chronological order:
- Thomas Leyh (@leyhline)
- nebulaeandstars (@nebulaeandstars)
- dmitry kim (@jsn)
- Julian Prein (@druckdev)
- Luke Atkinson (@LukeDAtkinson)
- Joe Planisky (@jplanisky)
==============================================================================
16. Changelog *vimwiki-changelog*