Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Common LISP code get borked in kakoune #86

Open
rapenne-s opened this issue Aug 14, 2020 · 3 comments
Open

Common LISP code get borked in kakoune #86

rapenne-s opened this issue Aug 14, 2020 · 3 comments

Comments

@rapenne-s
Copy link

I tried parinfer-rust for the first time using kakoune.

I installed parinfer-rust following the manual installation process, using git and make install to get the very latest version.

I opened a few lisp files that are known to work and the display in kakoune is totally wrong in some places, if I open the file with other editors the content is correct. I tried in the 3 different modes but it ends with t he same issue.

After fiddling, I came to a small example of code reproducing the issue.

tabs are important

Original code:

        (let ((title (format nil "~80a"
                       (if (< 80 (length (foo-title foo)))
                           (subseq (foo-title foo) 0 80)
                           (foo-title foo)))
          (replace title (foo-rawdate foo) :start1 (- (length title) (length (foo-rawdate foo)))))
        (getf *config* :srv-port)))

code displayed by kakoune:

        (let ((title (format nil "~80a"~80a"
                     (if (< 80 (length (foo-title foo)))foo)))
                      (subseq (foo-title foo) 0 80)le foo) 0 80)
                      (foo-title foo)))-title foo)))
           (replace title (foo-rawdate foo) :start1 (- (length title) (length (foo-rawdate foo))))))))))
                (getf *config* :srv-port)))rt)))
@eraserhd
Copy link
Owner

Hi!

I don't see any tabs in your example, so I'm not sure if you mean the indentation is important or maybe github ate the tabs? If the tab characters are important, can you link to a gist?

I don't see any problems loading this snippet as it is.

Parinfer doesn't know how wide tabs are and replaces them with two spaces as it applies its algorithm. That said, the editor plugins should run paren mode once and make a "correct" file before any other editing occurs.

I'm not sure where the duplication artifacts you are seeing could be coming from. Try piping the raw (with tabs, presumably) text to parinfer-rust -m paren. If the artifacts aren't there, try removing all your Kakoune plugins except for parinfer-rust, and see what happens.

@joulaud
Copy link

joulaud commented Jan 21, 2021

I have a minimal example showing the problem.
I confirm it is related to the use of tab character.

With parinfer-rust -m paren it does not replaces the tab by two spaces but it add two spaces before the tab.

$ cat <<EOF >x.scm
(test name
  (k	v))
EOF

$ cat x.scm | od -a
0000000   (   t   e   s   t  sp   n   a   m   e  nl  sp  sp   (   k  ht
0000020   v   )   )  nl

$ cat x.scm | parinfer-rust -m paren | od -a
0000000   (   t   e   s   t  sp   n   a   m   e  nl  sp  sp   (   k  sp
0000020  sp  ht   v   )   )  nl

It must break some offset calculation somewhere.

@joulaud
Copy link

joulaud commented Jan 21, 2021

The problem is probably in the use of -display-column option of kakoune select command when selecting the text to replace.
When there is tabs the selection is not complete and the end of the text to replace is kept.

We have indeed exactly the reverse problem as for #55

EDIT: disregard this comment, it is probably not relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants