Commit 65b048c1 authored by Laurent Montel's avatar Laurent Montel 😁

Make sure that remove space after quote

parent f9762412
......@@ -235,6 +235,7 @@ void RichTextComposerControlerTest::shouldRemoveQuote_data()
QTest::newRow("removequotewithnewline") << QStringLiteral(">foo\n>\n>bla\n>blo\n") << QStringLiteral("foo\n\nbla\nblo\n");
QTest::newRow("removequote2") << QStringLiteral(">foo\n\nbla\n>blo\nbli") << QStringLiteral("foo\n\nbla\nblo\nbli");
QTest::newRow("removequote2withspace") << QStringLiteral("> foo\n\nbla\n> blo\nbli") << QStringLiteral("foo\n\nbla\nblo\nbli");
QTest::newRow("twoquotes") << QStringLiteral(">>foo\n\nbla\n>blo\nbli") << QStringLiteral(">foo\n\nbla\nblo\nbli");
......
......@@ -448,7 +448,7 @@ QString RichTextComposer::quotePrefixName() const
}
}
int RichTextComposer::quoteLength(const QString &line) const
int RichTextComposer::quoteLength(const QString &line, bool oneQuote) const
{
if (!d->quotePrefix.simplified().isEmpty()) {
if (line.startsWith(d->quotePrefix)) {
......@@ -462,8 +462,10 @@ int RichTextComposer::quoteLength(const QString &line) const
const int lineLength(line.length());
for (int i = 0; i < lineLength; ++i) {
if (line[i] == QLatin1Char('>') || line[i] == QLatin1Char('|')) {
if (quoteFound && oneQuote) {
break;
}
quoteFound = true;
break;
} else if (line[i] != QLatin1Char(' ')) {
startOfText = i;
break;
......
......@@ -96,7 +96,7 @@ public:
QString quotePrefixName() const;
void setCursorPositionFromStart(unsigned int pos);
int quoteLength(const QString &line) const;
int quoteLength(const QString &line, bool oneQuote = false) const;
bool isLineQuoted(const QString &line) const;
const QString defaultQuoteSign() const;
void createActions(KActionCollection *ac);
......
......@@ -826,7 +826,7 @@ void RichTextComposerControler::slotRemoveQuotes()
int selectionEnd = cursor.selectionEnd();
while (block.isValid() && block.position() <= selectionEnd) {
cursor.setPosition(block.position());
int length = richTextComposer()->quoteLength(block.text());
const int length = richTextComposer()->quoteLength(block.text(), true);
if (length > 0) {
cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor, length);
cursor.removeSelectedText();
......
Markdown is supported
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