-
-
Notifications
You must be signed in to change notification settings - Fork 65
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
Enhance Matrix Shortcut with Multi-selection #394
base: main
Are you sure you want to change the base?
Enhance Matrix Shortcut with Multi-selection #394
Conversation
e468f2c
to
d40a3b9
Compare
Probably want to rebase and squash merge commits, as well as refactor commits. |
d40a3b9
to
54a0e20
Compare
|
||
isInsideAnEnv = ctx.isWithinEnvironment(ctx.pos, env); | ||
if (isInsideAnEnv) break; | ||
} | ||
|
||
if (!isInsideAnEnv) return false; | ||
|
||
// Take main cursor since ctx.mode takes the main cursor, weird behaviour is expected with multicursor because of this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry to be nitpicky but why was this removed. Weird behavior still arises when the main cursor is in different environment then the other cursors.
For example if nothing is selected in the main cursor but something is selected in another cursor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to apologize—I believe all features should be discussed to find the most convenient solution for everyone. I'm not sure what you mean by "weird behavior." I think in multi-selection cases, all selections should behave consistently—either all selected lines increase indentation or all selections are replaced with " & ", always following the main selection. Other potentially strange behaviors, like some selections being outside the environment or even outside the math block, shouldn’t be an issue because users using multi-selection should clearly know what they are doing. I hope you can provide more specific examples of what you mean by "weird behavior."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My original thought was that a cursor according to its "environment" (like math, code or text).
So any cursor that doesn't follow the behaviour of its environment is messy behaviour, but since I couldn't give a use case I just called it weird behaviour.
Cause if you have the following code where | is the cursor
\begin{pmatrix}
1 & 2 |
\end{pmatrix}
| some selected text|
then either the lines are indented or the selected text is replaced with a &, which can be weird but also no use case.
The main cursor was indeed taken to be consistent with the rest of the plugin and put the comment there if someone wanted ctx
cover multicursor.
But I still can't think of a use case, why someone would use cursors in different environments besides accidents, so it can be left out.
hope this explained it better.
I might reorganize the git commit history in the next couple of days. Feel free to point out any unexpected behavior. |
54a0e20
to
8484466
Compare
…get-environment-bound
…nt' into feature/matrix-shortcuts-trim-empty-line-after-environment
8484466
to
0a2cd87
Compare
…-shortcuts-trim-extra-align
…e/matrix-shortcut
0a2cd87
to
46f495b
Compare
This is a significant update with multiple enhancements and refactors to improve matrix shortcut handling and internal logic. Below is a summary of the changes made:
Users can now use multi-cursor with selection within matrix shortcuts, enabling more efficient edits.
isWithinEnvironment
The
isWithinEnvironment
function has been split into two separate functions:getEnvironmentBound
isWithinEnvironment
This refactor improves clarity and enhances the function's usability.
\hline
The logic now ignores adding a line break (
\\
) after encountering\hline
, ensuring no unnecessary line breaks are inserted in these situations.Optional Features:
true
)When enabled, extra spaces around the cursor are trimmed automatically. This helps address common cases where users accidentally add extra spaces, either by pressing the spacebar unintentionally or due to snippets automatically adding them. For example, pressing Tab after
"1(a lot of space)"
will result in"1 & "
rather than"1(a lot of space) & "
to prevent accidental spaces from accumulating.true
)This trims unnecessary alignment symbols that can occur if users accidentally press Tab at the end of a line. For instance, pressing Enter after
"1 & "
could result in an extra"&"
being inserted, but with this feature enabled, it will correctly turn into"1 \\"
instead of"1 & \\"
to avoid such mistakes.\\
After\hline
(defaultfalse
)If enabled, a line break
\\
will be inserted after\hline
.true
)When exiting an environment using Shift+Enter, an empty line after the environment is removed to prevent unnecessary blank spaces. For instance:
would transform to:
false
)If enabled, Shift+Enter will add a line break after exiting an environment. For example:
... 1 & 2 & 3 <- (cursor) \end{pmatrix}
will transform to:
These updates aim to enhance the user experience and provide better control over formatting and matrix shortcuts.