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

Should not add invisible markers to code #17

Open
laurent22 opened this issue Oct 6, 2023 · 3 comments
Open

Should not add invisible markers to code #17

laurent22 opened this issue Oct 6, 2023 · 3 comments
Assignees

Comments

@laurent22
Copy link

I'm wondering what is the purpose of this feature?

const MAGIC_CHARACTER = "​"

"zero width space that essentially brands changes made by this extension"

That seems a bit sneaky especially since it's not documented and people don't necessarily want to add invisible characters, as that could cause issues with certain tools or editors.

@zachhardesty7
Copy link
Owner

The extension should remove the magic character at the same time you see the comment appear. Its purpose is to maintain the expected cursor position when the cursor is at the end of the line, both when toggling the comment on or off AND when undoing and redoing. The extension used to use the only other solution I found: manually adjusting the cursor position. That has problems too, mainly that it adds an extra jump to the “Go back” and “Go forward” commands and that the user can see the cursor move.

I’ll try to come up with a better solution, but as far as I know, it’s still not possible to add text after a cursor that is at the end of a line without the cursor moving past the added text or the selection including the added text. In the meantime, I’ll make this feature (hack) optional, disable it by default, and try to add better error recovery to make sure the extension always removes the magic character, even if something else fails. Adding the JSDoc comment happens in 2 stages, so it’s possible it gets interrupted or fails and needs to clean up.

Also, @laurent22 would it be possible to share the code that made you see the magic character and where your cursor was in your code block? I can add a test case and fix it.

@zachhardesty7 zachhardesty7 self-assigned this Oct 9, 2023
@laurent22
Copy link
Author

That makes sense, thanks for clarifying. If that can help, it was this commit specifically that the // comments were converted to jsdoc:

laurent22/joplin@da40036#diff-b7c06e2041e9742252b0f59c604d1e3ff8479854dac3a49b58989fd78ae2a057L23

I guess I was selecting a block of text, then using the command to toggle to jsdoc. That added this extra characters at the end of each jsdoc block if I remember correctly.

@zachhardesty7
Copy link
Owner

@laurent22 Yes, thank you for the reproduction! I'll see if I can mess around with it and add a test case to fix that. I know that there are still various issues with converting entire blocks of comments, but it definitely shouldn't keep around those zero-width-spaces, even if the cursor isn't in the perfect place.

I published v1.11.0 which disables the "cursor hack" by default and adds an setting to enable it (if desired). I'll probably update the default to enabled once I address this issue and write a few more test cases for selections over multiple lines.

(PS I understand how this could be a frustrating experience, but thank you for revising the marketplace review 🙂)

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

2 participants