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

fix(blockwise-visual): handle double-width chars and tabs #1596

Merged
merged 8 commits into from
Nov 12, 2023

Conversation

xiyaowong
Copy link
Collaborator

improvement: the selection direction is consistent with nvim

Issue - Fixed

@xiyaowong xiyaowong changed the title fix(visual): fix synchronization of blockwise visual fix(visual): consider tab indent in blockwise visual mode Nov 8, 2023
@trkoch
Copy link
Collaborator

trkoch commented Nov 8, 2023

@xiyaowong Not sure I can follow the GIF. The issue you're fixing is that some characters are not selected which should? I merged the PR in my build and will report regressions, if any.

@xiyaowong xiyaowong marked this pull request as draft November 9, 2023 00:17
@xiyaowong xiyaowong changed the title fix(visual): consider tab indent in blockwise visual mode fix(visual): wrong selections when double-width chars or tabs exist Nov 9, 2023
@xiyaowong xiyaowong marked this pull request as ready for review November 9, 2023 10:18
@xiyaowong xiyaowong changed the title fix(visual): wrong selections when double-width chars or tabs exist fix(blockwise-visual): handle double-width chars and tabs Nov 12, 2023
@xiyaowong xiyaowong merged commit c554c06 into vscode-neovim:master Nov 12, 2023
8 checks passed
@xiyaowong xiyaowong deleted the fix/visual-selection branch November 12, 2023 15:12
@theol0403
Copy link
Member

Isn't there a built in vim function to convert display col to col? Could this PR not be simplified to just converting the column before sending it to VS code? This code seems a little complex.

@xiyaowong
Copy link
Collaborator Author

Isn't there a built in vim function to convert display col to col?

Oh! I forgot to search for the built-in function. There is virtcol2col

@xiyaowong xiyaowong restored the fix/visual-selection branch November 12, 2023 16:33
xiyaowong added a commit that referenced this pull request Nov 12, 2023
@xiyaowong
Copy link
Collaborator Author

@theol0403 Not sure if virtcol2col can simplify the code, after all, we still need to convert byte-index to char-index. And this function depends on a window

@theol0403
Copy link
Member

Isn't there also a function to convert char to byte char?

@xiyaowong
Copy link
Collaborator Author

xiyaowong commented Nov 12, 2023

vim.str_utfindex

I'll refactor it when I have time.😪

@theol0403
Copy link
Member

@xiyaowong
Copy link
Collaborator Author

It seems almost the same

vim.str_utfindex is widely used in nvim-lsp. Maybe it's better?. I'm not sure. I haven't used any of these functions.

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

Successfully merging this pull request may close these issues.

None yet

3 participants