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

RunOnSave causing an issue when using autosave. #14

Open
donk3ylee opened this issue Feb 27, 2024 · 3 comments
Open

RunOnSave causing an issue when using autosave. #14

donk3ylee opened this issue Feb 27, 2024 · 3 comments

Comments

@donk3ylee
Copy link

I wrote this RFC on headwinds github page but after seeing the package is not well maintained I figured I would use your fork instead in the hope of getting this issue fixed. My apologies if some of the settings described here are not named the same but I'm sure you will get the idea:

RunOnSave feature is causing an issue when using vscode autosave. The issue is that while I'm typing my tailwind classes, vscode autosaves triggering headwind to reorder. As this reorder applies the cursor does not follow the original classname and I end up writing half of my classname in the center of another, corrupting that classname and leaving the classname I'm trying to declare half written and lost somewhere else in the string.

Could you add another cofiguration setting say headwind.triggerPoint where the user can choose options "runOnSave" or "runOnLineOut". The runOnLineOut would be an option whereby the reordering would happen when the user focuses away from the line or maybe when the cursor focuses away from the class value declaration string (anything within the ""). Or just move the cursor with the reordering of possible, you get the idea.

It's a very handy extension for code readability and therefore productivity. It just becomes unusable when users have vscode autosave enabled and it gets triggered every 5 seconds, corrupting their tailwind classnames.

Thanks,
Donk3yLee.

@Trapfether
Copy link
Owner

@donk3ylee That sounds very frustrating. Definitely worth fixing. I'll dig into this later this week. My approaches will generally prefer automatic detection so when people install the extension it "just works". So I'll try and detect active editing and disable reordering. My first approach will be detecting if the selection (cursor is a zero width selection) lies within the detected text range to be reordered and skip just that range. Another approach I might try is attempting to stick the cursor to its position relative to class it currently is within / on the end of as you suggested. If I can't make either of those work, I will investigate the addition of another configuration option.

Aside from those, I think that maintaining cursor position is a generally good idea and so I will make sure that when we change the length of className - such as removing duplicates or extra whitespace - we update the cursor position accordingly.

Thank you for taking the time to submit this issue and bring this to my attention!

@donk3ylee
Copy link
Author

donk3ylee commented Feb 27, 2024 via email

@SantanuDatta
Copy link

I have been searching for a solution for so long now, I hope the work is still going on this, and an update soon, thanks

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