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

[FEATURE] Delaying the reveal of concealed math #283

Open
Brenzle opened this issue Apr 22, 2024 · 3 comments · May be fixed by #332
Open

[FEATURE] Delaying the reveal of concealed math #283

Brenzle opened this issue Apr 22, 2024 · 3 comments · May be fixed by #332
Labels
enhancement New feature or request

Comments

@Brenzle
Copy link

Brenzle commented Apr 22, 2024

Description of the Problem

When moving the text cursor left or right through an equation with conceal mode turned on, it's impossible to know how many clicks you need to select exactly what you want or to position the cursor where you want. If I see I'm three characters from the place I want to get to, if it's concealed math then I'm further away. Real LaTeX syntax will be revealed every time I get to a new symbol and be hidden once I pass it, which is very annoying.

Description of the Solution

A time delay, where in the first x seconds a symbol of concealed math that I'm next to won't be replaced with real underlying LaTeX.

1s seems good to start with, but a configurable option would be the best.

That way it is possible to edit equations faster, more predictable, and easier - not requiring the user to think about syntax when editing and letting him focus on math.

Additional information

When a section of text is selected, the symbols should convert to LaTeX syntax after the time delay, and should keep the accurate selection over themselves, if possible.

If the text cursor is positioned between two "concealed math" symbols and the user starts typing, the symbols won't convert to real syntax until the cursor has been idle for longer than x.

Open for suggestions

If anyone who reads this finds that it would make more sense to add/modify a part of the idea, please comment so we can discuss it and find the best solution. :)

@Brenzle Brenzle added the enhancement New feature or request label Apr 22, 2024
@bdm-k
Copy link
Contributor

bdm-k commented Apr 26, 2024

This feature will be very useful if implemented.

I've come up with some rough ideas for the implementation, so I'd like to share them.

Let's use the formula $1 \leq 2$ as an example, where the part \leq needs to be properly concealed. We define three types of positions seen from this part.

  • Type A: entirely within the part (e.g., $1 \|leq 2$)
  • Type B: just at the edge of the part (e.g. $1 |\leq 2$)
  • Type C: apart from the part (e.g., $1| \leq 2$)

We determine whether to conceal \leq based on which type the current cursor position falls into. If the type is A, \leq is not concealed now, and we still don't want to conceal it. If the type is C, we can always conceal \leq.

Things become a bit more complicated when the type is B. In this case, we use information about whether or not \leq is concealed now. If it is not concealed, we still don't conceal it. If it is concealed, we keep it concealed. Also, we notify a certain manager to stop concealing it with a time delay.

A simple bulleted summary is as follows:

  • Current cursor position is type A → Do not conceal
  • Current cursor position is type C → Conceal
  • Current cursor position is type B:
    • \leq is concealed now → Conceal and notify the manager
    • \leq is not concealed now → Do not conceal

Here is an explanation regarding the manager. Generally, the manager should uncover the provided parts of formulas with a time delay. However, the manager should cancel all the actions if the cursor has moved before the delay.

@artisticat1
Copy link
Owner

artisticat1 commented Apr 27, 2024

This feature will be very useful if implemented.

I've come up with some rough ideas for the implementation, so I'd like to share them.

Let's use the formula $1 \leq 2$ as an example, where the part \leq needs to be properly concealed. We define three types of positions seen from this part.

  • Type A: entirely within the part (e.g., $1 \|leq 2$)
  • Type B: just at the edge of the part (e.g. $1 |\leq 2$)
  • Type C: apart from the part (e.g., $1| \leq 2$)

We determine whether to conceal \leq based on which type the current cursor position falls into. If the type is A, \leq is not concealed now, and we still don't want to conceal it. If the type is C, we can always conceal \leq.

Sure, that sounds reasonable.

However, I don't believe this alone will resolve the problem of not knowing exactly how many characters left/right you need to move to get to another position. We probably need to use atomicRanges, so that pressing when you are in the position $1 |≤ 2$ takes you directly to $1 ≤| 2$.

@bdm-k
Copy link
Contributor

bdm-k commented Sep 5, 2024

@shunby and I are currently working on implementing this feature. We plan to submit a PR in a few weeks!

@bdm-k bdm-k linked a pull request Sep 27, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants