Allow setting a code block on a line that already has text (it will start a newline for the codeblock)

This commit is contained in:
Miguel Jacq 2025-12-23 13:42:33 +11:00
parent b925d2e89e
commit 0a64dc525d
Signed by: mig5
GPG key ID: 59B3F0C24135C6A9
2 changed files with 5 additions and 2 deletions

View file

@ -2,6 +2,7 @@
* Add .desktop file for Debian * Add .desktop file for Debian
* Fix Pomodoro timer rounding so it rounds up to 0.25, but rounds to closest quarter (up or down) for minutes higher than that, instead of always up to next quarter. * Fix Pomodoro timer rounding so it rounds up to 0.25, but rounds to closest quarter (up or down) for minutes higher than that, instead of always up to next quarter.
* Allow setting a code block on a line that already has text (it will start a newline for the codeblock)
# 0.7.5 # 0.7.5

View file

@ -919,8 +919,10 @@ class MarkdownEditor(QTextEdit):
before = line[:pos_in_block] before = line[:pos_in_block]
# "before" currently contains whatever's before the *third* backtick. # "before" currently contains whatever's before the *third* backtick.
# We trigger only when the line is (whitespace + "``") before the caret. # Trigger when the user types a *third consecutive* backtick anywhere on the line.
if before.endswith("``") and before.strip() == "``": # (We require the run immediately before the caret to be exactly two backticks,
# so we don't trigger on 4+ backticks.)
if before.endswith("``") and (len(before) < 3 or before[-3] != "`"):
doc = self.document() doc = self.document()
if doc is not None: if doc is not None:
# Remove the two backticks that were already typed # Remove the two backticks that were already typed