zk-org / zk-nvim

Neovim extension for zk
https://github.com/zk-org/zk
GNU General Public License v3.0
530 stars 42 forks source link

fix selection of non ascii title #84

Closed artur-shaik closed 1 year ago

artur-shaik commented 2 years ago

I made a conversion bytes based indexes of character position to char based before execute zk.new command. So now I can successfully extract titles from Cyrillic encoded text.

UnkwUsr commented 1 year ago

Sadly, this patch have a few bugs:

  1. This kills previously worked function with selecting multiple lines (when first line becomes a title, and all trailing becomes a description). The problem is in parent note, where should be placed our new link.

    Example:

    example title
    description

    Visual select this two lines, make ZkNewFromTitleSelection and see messed result:

    [example title](usi2)description
  2. This messes whole line (even if selected only part of it) if you do visual select till the latest symbol on the line

    Example:

    * asd my future title
         ^ cursor is there

    Type v$ and make ZkNewFromTitleSelection. Result:

    [my future title](b7ku)my future title

    (Also see how heading text ("* asd ") disappeared)

    To avoid messing we can visual select with v$h (just jump to one symbol left), so I think problem is with newline character.

    P.S. before this commit v$ also worked without messing

@mickael-menu @artur-shaik Should I create issue for this or will you revert commit and continue work on this pull req?

mickael-menu commented 1 year ago

Thanks for spotting this @UnkwUsr. I will revert the PR for now, feel free to open a new PR to implement a fixed version @artur-shaik.