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

Implement UserDataHolder for EditorDataContext #468

Merged

Conversation

PHPirates
Copy link
Contributor

This PR fixes Hannah-Sten/TeXiFy-IDEA#2230

How to reproduce the issue

  • In build.gradle.kts, add a dependency on plugin TeXiFy-IDEA: nl.rubensten.texifyidea:0.7.14
  • runIde
  • Go to Settings > Editor > Code Style, set Hard wrap at to 120 characters and enable Wrap on typing.
  • Create a LaTeX file (.tex) and paste the following content:
\begin{itemize}
    \item This is the first item: pressing enter at the end of this line will insert an \verb|\item| on the next line.
    \item This line should hard-wrap to a next line without inserting an \verb|\item| in front of it, when typing here:
\end{itemize}
  • Continue typing after ... when typing here:
  • Expected behaviour, and this is what happens when IdeaVim is not installed: the text is wrapped to the next line, no \item is inserted.
  • Actual behaviour with IdeaVim installed: \item is inserted at the beginning of the next line.

Issue description

  • The AutoHardWrapHandler:188 saves data for a custom key to the data context. Without IdeaVim, the data context is an EdtDataContext, with IdeaVim the EditorDataContext which has as contextDelegate the EdtDataContext.
  • TeXiFy implements a typed handler, which checks for this data key in order to determine whether an auto hard wrap is in progress.
  • Without IdeaVim, TeXiFy can retrieve the data from the context. With IdeaVim, the data cannot be retrieved from the context (DataManager#loadFromDataContext) because the context is not a UserDataHolder.

Issue fix

This PR fixes that last point, so that the IdeaVim data context now correctly delegates the user data.
I verified that it fixes the problem, but please check if this doesn't break something else.

… AutoHardWrapHandler can store user data in the context delegate.
@AlexPl292
Copy link
Member

Hi there! Thank you for your contribution.
That seems to be a save fix, so I'll merge this without additional checks.

@AlexPl292 AlexPl292 merged commit 4b2ed33 into JetBrains:master Feb 24, 2022
@PHPirates
Copy link
Contributor Author

Great, thanks a lot!

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.

New \item on line wrap when IdeaVim is installed
2 participants