Commit bbc77590 authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

markdown: Only remove text if we're going to add something

Otherwise things get confused

BUGS: 443057
(cherry picked from commit 3b8cbc33)
parent 51d91bfd
...@@ -194,10 +194,10 @@ void Converter::convertImages(const QTextBlock &parent, const QDir &dir, QTextDo ...@@ -194,10 +194,10 @@ void Converter::convertImages(const QTextBlock &parent, const QDir &dir, QTextDo
QTextCursor cursor(textDocument); QTextCursor cursor(textDocument);
cursor.setPosition(textFragment.position(), QTextCursor::MoveAnchor); cursor.setPosition(textFragment.position(), QTextCursor::MoveAnchor);
cursor.setPosition(textFragment.position() + textFragment.length(), QTextCursor::KeepAnchor); cursor.setPosition(textFragment.position() + textFragment.length(), QTextCursor::KeepAnchor);
cursor.removeSelectedText();
const QString imageFilePath = QDir::cleanPath(dir.absoluteFilePath(textCharFormat.toImageFormat().name())); const QString imageFilePath = QDir::cleanPath(dir.absoluteFilePath(textCharFormat.toImageFormat().name()));
if (QFile::exists(imageFilePath)) { if (QFile::exists(imageFilePath)) {
cursor.removeSelectedText();
format.setName(imageFilePath); format.setName(imageFilePath);
const QImage img = QImage(format.name()); const QImage img = QImage(format.name());
...@@ -206,6 +206,7 @@ void Converter::convertImages(const QTextBlock &parent, const QDir &dir, QTextDo ...@@ -206,6 +206,7 @@ void Converter::convertImages(const QTextBlock &parent, const QDir &dir, QTextDo
cursor.insertImage(format); cursor.insertImage(format);
#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) #if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)
} else if ((!textCharFormat.toImageFormat().property(QTextFormat::ImageAltText).toString().isEmpty())) { } else if ((!textCharFormat.toImageFormat().property(QTextFormat::ImageAltText).toString().isEmpty())) {
cursor.removeSelectedText();
cursor.insertText(textCharFormat.toImageFormat().property(QTextFormat::ImageAltText).toString()); cursor.insertText(textCharFormat.toImageFormat().property(QTextFormat::ImageAltText).toString());
#endif #endif
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment