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

Update QMarkdownTextEdit::handleBracketClosing to fix issue caused by #208 #211

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

com3dian
Copy link
Contributor

@com3dian com3dian commented Aug 6, 2024

No description provided.

@pbek
Copy link
Owner

pbek commented Aug 6, 2024

Can you please provide an example Markdown with a bracket closing issue that this PR is fixing?

@com3dian
Copy link
Contributor Author

Hi @pbek , sorry for this late reply but I was busy recently.

So this PR fixed the issue caused by my last one (#208), in which I changed index calculation method to consider indented white-spaces:
https://github.com/pbek/qmarkdowntextedit/pull/208/files/eebf03aa09e7366d68f3d16fa8ecdfc8ca4b8d01

However in line 722,

bool isNextAsterisk = pib < text.length() && text.at(pib) == '*';

and line 724,

if (pib < text.length() && !isMaybeBold && !text.at(pib).isSpace()) {

no check for negative pib is there is there yet, so that may cause a crash. When the user have the following line:

 
  |      some text
^ ^ ^^^^^
  cursor
// In this case the `text` variable is "some text" while `pib` is -6 (original index:3 - indented length:9)

and type asterisk * will trigger this issue.

By adding the condition pib > 0, the crash will be fixed and the method will return without triggering any bracket completions, which suppose the user has a multi-level list.

@pbek
Copy link
Owner

pbek commented Aug 11, 2024

Can you please provide a step-by-step instruction what to do to reproduce the crash, so I can test this?

@com3dian
Copy link
Contributor Author

Sure,

If the user start a newline like

  |      some text
^ ^ ^^^^^
  cursor
// In this case the `text` variable is "some text" while `pib` is -6 (original index:3 - indented length:9)

and the vertical bar is the cursor, then if the user input an asterisk * a crash will be triggered.

@pbek
Copy link
Owner

pbek commented Aug 11, 2024

I wasn't able to reproduce this.

Can you please provide a step-by-step instruction what to type to reproduce the crash?

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.

2 participants