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 #207 #208

Merged
merged 2 commits into from
Aug 4, 2024

Conversation

com3dian
Copy link
Contributor

@com3dian com3dian commented Aug 3, 2024

Adjusted index calculation in line 720 to include removed white-space;

Adjusted index calculation in line 720 to include removed white-space;
@@ -717,7 +717,7 @@ bool QMarkdownTextEdit::handleBracketClosing(const QChar openingCharacter,
// Remove whitespace at start of string (e.g. in multilevel-lists).
const QString text = cursor.block().text().remove(QRegularExpression("^\\s+"));

const int pib = cursor.positionInBlock();
const int pib = cursor.positionInBlock() - cursor.block().text().length() + text.length();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good one.

Would suggest using extra () parens to make the addition/subtraction order clear

Add brackets to subtract the length of leading spaces;
@pbek pbek requested a review from Waqar144 August 4, 2024 19:08
@pbek pbek merged commit a06cfb1 into pbek:develop Aug 4, 2024
22 checks passed
@com3dian
Copy link
Contributor Author

com3dian commented Aug 4, 2024

Hi @Waqar144 @pbek, sorry but it is okay if you can revert the merge? I just found a issue after my commits with line 723

bool isNextAsterisk = pib < text.length() && text.at(pib) == '*';
as now the pib could be negative and will cause issue QString indexing.

I will test more and come back to you later next week for this PR, thank you!

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.

3 participants