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

Autocomplete and autocorrect #29

Open
stefnotch opened this issue Dec 5, 2022 · 11 comments
Open

Autocomplete and autocorrect #29

stefnotch opened this issue Dec 5, 2022 · 11 comments

Comments

@stefnotch
Copy link
Owner

Because I'm working on a math formula editor:
In a lovely editor of your dreams, what would you expect to type to get $$\limsup_{x \to \infty} 2x$$ ?

Here are a few different "shortcut" variants: Do note that they are closer to macros/autocomplete suggestions than they are to conventional shortcuts.

Typing and it automatically applies the shortcut, see https://cortexjs.io/mathlive/ and http://mathquill.com/

  • Should typing lim followed by hitting the Backspace result in li being typed?

Indicating that you're using a shortcut by typing \lim and then hitting enter

  • Should that automatically submit the shortcut whenever possible?

Typing lim and then it suggests the shortcut, like VSCode does when you type for. See also https://www.mathicando.com/#!/demo
-- stefnotch

@stefnotch
Copy link
Owner Author

stefnotch commented Dec 24, 2022

Old note:
Mathlive autocomplete (accept with space, I guess)
limn[space] turns into lim_{n \to \infin}
limnto-[space] turns into lim n to -infinity
lim[space] turns into lim
liminf is \lim \inf
What shortcut does Mathcad have for infinity? (00 or oo could work?)

This was referenced Jan 1, 2023
@stefnotch
Copy link
Owner Author

Inside a $\lim_{cat \to 42} |$, the word "cat" is very much something that the autocomplete could suggest, if the user provides a parser that tracks variables and such.

@stefnotch
Copy link
Owner Author

stefnotch commented May 25, 2023

Open question:

  • Should typing in the next token automatically accept the autocompletion (if it was a perfect match)? e.g. Typing \sum_

Bonus points if for a sum symbol, it can show "sum as text" in its autocomplete suggestions.

@stefnotch
Copy link
Owner Author

stefnotch commented Jun 1, 2023

What should space do? Accept or reject? Also, should a^2+4 followed by space jump out of the exponent?

Space should simply insert a space character. We need that for $a\ b$ being two separate symbols. After all, we have a greedy lexer/parser, and thus we need a way to "stop" it.

@stefnotch
Copy link
Owner Author

Space could also be used as a placeholder, and as a way of pushing symbols around.

e.g. When we have $\frac{a}{\color{blue}|\color{black}b}$, then hitting space could do something like $\frac{a}{\quad \color{blue}|\color{black}}b$

@stefnotch
Copy link
Owner Author

image
Oh look at what super smart thing MathICanDo does!

@stefnotch stefnotch moved this to Planned in MathML Editor Jul 1, 2023
@stefnotch stefnotch moved this from Planned to Doing in MathML Editor Jul 1, 2023
@stefnotch
Copy link
Owner Author

stefnotch commented Jul 2, 2023

How does autocomplete even work when there are multiple cursors?

Code_2023-07-02-0310.webm
I'm autocompleting lim but I also have a second cursor at an empty place.

Answer: Not sure if there is even an intuitive answer. So doing literally anything[1] is fine.

[1] Anything other than failing horribly.

@stefnotch stefnotch changed the title Autocomplete Autocomplete and autocorrect Jul 6, 2023
@stefnotch
Copy link
Owner Author

stefnotch commented Jul 29, 2023

Regarding autocorrect

/_^ logic is simply

  1. Input symbol()
  2. Check if it's an escaped token after parsing
  3. If it's not an escaped token, do the special thing.

Reasoning is very simple: it'd be annoying if 1_a_b suddenly behaved differently, just because someone implemented a _italics_ parser. Same goes for a^= and other stuff.

That logic is hardcoded, which is fine, I think.

@stefnotch
Copy link
Owner Author

stefnotch commented Aug 8, 2023

The delayed autocorrect can handle quite a lot. The user can type stuff like inN to get $\in \mathbb{N}$. Notice how there's no space between the $in$ and the N.

That is because $\in$ is the only sensible symbol for in. So the parser picks up on that and makes use of the knowledge.

Depending on user testing, we might have to scale it back though. Maybe it is confusing?

@stefnotch
Copy link
Owner Author

@stefnotch
Copy link
Owner Author

Vscode snippets
sqrt => \sqrt{$1}
root => \sqrt[$1]{$2}
.box() => Box(prev token)
/ => \frac{prev}{next}
/ => escaped slash
"/" or "/"

What if I change the autocompletion logic to actually look at the syntax tree? Well then => wouldn't work?
But what if I change it to be able to also look at the syntax tree?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Doing
Development

No branches or pull requests

1 participant