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

On enter rule don't use the proper insert spaces / tab width when those settings are changed #460

Closed
angelozerr opened this issue Oct 28, 2022 · 0 comments · Fixed by #517

Comments

@angelozerr
Copy link
Contributor

As the compute of insert spaces / tabs is cached here https://github.com/eclipse/tm4e/blob/cb5f4728cd3f0f1b2eaa4f2836519309ffacd20c/org.eclipse.tm4e.languageconfiguration/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/LanguageConfigurationAutoEditStrategy.java#L283 there is a bug with on enter rule which is not updated when those settings are changed.

I noticed that while my editorconfig implementation. See the following demo:

JSONEditorConfigDemo

In the demo the jsonc file have spaces (we don't see that, but it was initialized with that). When this settings is changed with tabs and when we press on on enter between {}, it generates spaces instead of tabs. It is because https://github.com/eclipse/tm4e/blob/cb5f4728cd3f0f1b2eaa4f2836519309ffacd20c/org.eclipse.tm4e.languageconfiguration/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/LanguageConfigurationAutoEditStrategy.java#L283 was cached.

To fix this issue we should avoid having a cache and just have the capability to read the tabs / insert spaces settings from the editor preferences store. This fixes requires eclipse-platform/eclipse.platform.text#88

I remember too that we use uggly reflection to get information of insert spaces at https://github.com/eclipse/tm4e/blob/cb5f4728cd3f0f1b2eaa4f2836519309ffacd20c/org.eclipse.tm4e.languageconfiguration/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/utils/TextUtils.java#L175 we should avoid doing that.

Another uggly code is here https://github.com/eclipse/tm4e/blob/cb5f4728cd3f0f1b2eaa4f2836519309ffacd20c/org.eclipse.tm4e.languageconfiguration/src/main/java/org/eclipse/tm4e/languageconfiguration/internal/LanguageConfigurationAutoEditStrategy.java#L293 to get the editor of the IAutoEditStrategy I created an issue at eclipse-platform/eclipse.platform.text#108 (comment) to get easily the editor just by implementing ITextEditorAware.

angelozerr added a commit to angelozerr/tm4e that referenced this issue Oct 28, 2022
angelozerr added a commit to angelozerr/tm4e that referenced this issue Oct 28, 2022
angelozerr added a commit to angelozerr/tm4e that referenced this issue Oct 28, 2022
angelozerr added a commit to angelozerr/tm4e that referenced this issue Apr 3, 2023
angelozerr added a commit to angelozerr/tm4e that referenced this issue Apr 3, 2023
angelozerr added a commit to angelozerr/tm4e that referenced this issue Apr 3, 2023
angelozerr added a commit to angelozerr/tm4e that referenced this issue Apr 3, 2023
angelozerr added a commit to angelozerr/tm4e that referenced this issue Apr 3, 2023
angelozerr added a commit to angelozerr/tm4e that referenced this issue Apr 3, 2023
mickaelistria pushed a commit that referenced this issue Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant