Skip to content

Commit d94de65

Browse files
committed
fix #36276: Deleting a line break in the middle of text automatically adds one at the end
1 parent 5bf0f10 commit d94de65

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

libmscore/text.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1654,6 +1654,8 @@ bool Text::edit(MuseScoreView*, Grip, int key, Qt::KeyboardModifiers modifiers,
16541654
CharFormat* charFmt = _cursor.format(); // take current format
16551655
_layout.insert(line + 1, curLine().split(_cursor.column()));
16561656
_layout[line].setEol(true);
1657+
if (_layout.last() != _layout[line+1])
1658+
_layout[line+1].setEol(true);
16571659

16581660
_cursor.setLine(line+1);
16591661
_cursor.setColumn(0);
@@ -1876,6 +1878,8 @@ bool Text::deletePreviousChar()
18761878
for (const TextFragment& f : l1.fragments())
18771879
l2.fragments().append(f);
18781880
_layout.removeAt(_cursor.line());
1881+
if (_layout.last() == l2)
1882+
l2.setEol(false);
18791883
_cursor.setLine(_cursor.line()-1);
18801884
}
18811885
else {
@@ -1899,6 +1903,8 @@ bool Text::deleteChar()
18991903
for (const TextFragment& f : l2.fragments())
19001904
l1.fragments().append(f);
19011905
_layout.removeAt(_cursor.line() + 1);
1906+
if (_layout.last() == l1)
1907+
l1.setEol(false);
19021908
return true;
19031909
}
19041910
return false;
@@ -2117,13 +2123,14 @@ void Text::deleteSelectedText()
21172123
const TextBlock& l2 = _layout[r2];
21182124
for (const TextFragment& f : l2.fragments())
21192125
l1.fragments().append(f);
2120-
21212126
_layout.removeAt(r2);
21222127
QMutableListIterator<TextBlock> i(_layout);
21232128
while (i.hasNext()) {
21242129
if (toDelete.contains(i.next()))
21252130
i.remove();
21262131
}
2132+
if (_layout.last() == l1)
2133+
l1.setEol(false);
21272134
}
21282135
_cursor.setLine(r1);
21292136
_cursor.setColumn(c1);

libmscore/text.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ class TextBlock {
147147
public:
148148
TextBlock() {}
149149
bool operator ==(const TextBlock& x) { return _text == x._text; }
150+
bool operator !=(const TextBlock& x) { return _text != x._text; }
150151
void draw(QPainter*, const Text*) const;
151152
void layout(Text*);
152153
const QList<TextFragment>& fragments() const { return _text; }

0 commit comments

Comments
 (0)