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

May something wrong with concealcursor. #6375

Open
yangxyo opened this issue Jul 2, 2020 · 17 comments
Open

May something wrong with concealcursor. #6375

yangxyo opened this issue Jul 2, 2020 · 17 comments

Comments

@yangxyo
Copy link

yangxyo commented Jul 2, 2020

I want to hide the char of the first-level tab.

set listchars=tab:\¦\ ,trail:■,extends:>,precedes:<,nbsp:+
set list
hi SpecialKey ctermfg=239 ctermbg=202

set conceallevel=1
set concealcursor=inc
call matchadd('Conceal', '^\t', 0, -1, {'conceal':'	'})
hi Conceal ctermfg=NONE ctermbg=NONE

Screenshots

VIM - Vi IMproved 8.2
MacOS 10.15.5 

I don't know whether it is a bug. So I created a blank one.

@k-takata
Copy link
Member

k-takata commented Jul 2, 2020

Could you explain what is your expected behavior?

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

set listchars=tab:\¦\ ,trail:■,extends:>,precedes:<,nbsp:+
set list
hi SpecialKey ctermfg=239 ctermbg=202

It started like this:

But I woloud like this(Do not show the first-level tab char):

So I add:

set conceallevel=1
set concealcursor=inc
call matchadd('Conceal', '^\t', 0, -1, {'conceal':'	'})
hi Conceal ctermfg=NONE ctermbg=NONE

But actually show(When I move the cursor the indent will change, it's strange):

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

Could you explain what is your expected behavior?

Is there any way to solve it?

@chrisbra
Copy link
Member

chrisbra commented Jul 2, 2020

While I think this is already stretching what an editor should do a bit too much by using concealing and listchars, it looks like a bug. I see rendering issues on the line where the cursor is (displaying different characters). In addition, it looks like the concealing code does not handle using a tab as a conceal character very well.

@chrisbra
Copy link
Member

chrisbra commented Jul 2, 2020

reproduced with 8.2.1114 using the following snippet:

set listchars=tab:\¦\ ,trail:■,extends:>,precedes:<,nbsp:+
set list ts=8
hi SpecialKey ctermfg=239 ctermbg=202
set conceallevel=1
set concealcursor=inc
call matchadd('Conceal', '^\t', 0, -1, {'conceal':"\t"})
hi Conceal ctermfg=NONE ctermbg=NONE

	"foobar eins 	zwei
	"foobar eins 	zwei
	"foobar eins 	zwei

Note how the line where the cursor is is rendered differently (wrong). See commandline for the actual content.
grafik

@k-takata
Copy link
Member

k-takata commented Jul 2, 2020

:help matchadd() says:

			conceal	    Special character to show instead of the
				    match (only for |hl-Conceal| highlighted
				    matches, see |:syn-cchar|)

and :help :syn-cchar says:

The character cannot be a control character such as Tab.

So, this is a limitation?

@chrisbra
Copy link
Member

chrisbra commented Jul 2, 2020

Oh yes, indeed. I remember having read this in the past, but missed it.

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

and :help :syn-cchar says:

The character cannot be a control character such as Tab.

So, this is a limitation?

Because of this, I use {'conceal':' '}), rather than {'conceal':' \t'})
And I do realize it.
As the second image:
#6375 (comment)
However, as the third image, when my cursor passes the line, it crashes.

@chrisbra
Copy link
Member

chrisbra commented Jul 2, 2020

Because of this, I use {'conceal':' '}), rather than {'conceal':' \t'})

That was not in your original issue. It contained a literal tab, I just converted it to use \t instead.

However, as the third image, when my cursor passes the line, it crash.

What do you mean here? Can you post a backtrace please?

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

image

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

It seems set concealcursor=inc, its performance doesn't like the help: concealcursor.

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

😂But,in fact, I don't want to feedback bug, I'm looking for the way to "hide the character of the first-level tab".

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

It not only the indent unusual, but it also completes collapse.
QQ20200702-151432-HD 2020-07-02 15_15_18
I only type the "j->o -> fo -> dd -> dsfaf->k"

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

@chrisbra

Because of this, I use {'conceal':' '}), rather than {'conceal':' \t'})

That was not in your original issue. It contained a literal tab, I just converted it to use \t instead.

I first don't think: {'conceal':' '} == {'conceal':' \t'} , so I use {'conceal':' '} 😂.

However, I still think it is sth. wrong because it worked first, it is that the set concealcursor=inc does not work as far as I see, hah.

And I only need sth. to replace or hide the ¦ of '^\t'. However, I don't allow to use four spaces , because it is cstr that can't be used for matchadd of Vim now, it will be analyzed to one space.

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

@chrisbra

While I think this is already stretching what an editor should do a bit too much by using concealing and listchars

Is there a way toset listchars =tab:\ \ for the first-level tab, while set listchars =tab:\¦\ for others?

@chrisbra
Copy link
Member

chrisbra commented Jul 2, 2020

Is there a way toset listchars =tab:\ \ for the first-level tab, while set listchars =tab:\¦\ for others?

No, listchars is intended to be used for all characters that follow. Perhaps you should try to explain, what actual problem you are trying to solve. I must confess, I couldn't follow your messages and it is not clear to me what you want to achieve and why.

@yangxyo
Copy link
Author

yangxyo commented Jul 2, 2020

I'm so sorry.

What actual problem you are trying to solve

I need the Indent alignment lines.

set listchars=tab:\¦\ ,trail:■,extends:>,precedes:<,nbsp:+
set list
hi SpecialKey ctermfg=239 ctermbg=202

It started like this:

But I would like this which does not display the first-level tab character:

Why

I think It will be more reasonable, simple, and beautiful. "Radish or cabbage; each to his own delight."
I hope I explained it clearly.🌚

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