- fix: "move selection up/down" of whole lines selection are no correctly handled.
This commit is contained in:
parent
ee26d9d0a0
commit
257b81ca3f
1
NEWS.md
1
NEWS.md
|
@ -2,6 +2,7 @@ Red Panda C++ Version 2.25
|
||||||
|
|
||||||
- fix: Symbol completion of '(' before selection may fail, if cursor is at the beginning of the selection.
|
- fix: Symbol completion of '(' before selection may fail, if cursor is at the beginning of the selection.
|
||||||
- change: Symbol completion of '{' won't insert extra new lines.
|
- change: Symbol completion of '{' won't insert extra new lines.
|
||||||
|
- fix: "move selection up/down" of whole lines selection are no correctly handled.
|
||||||
|
|
||||||
Red Panda C++ Version 2.24
|
Red Panda C++ Version 2.24
|
||||||
|
|
||||||
|
|
|
@ -2161,9 +2161,12 @@ void QSynEdit::doMoveSelUp()
|
||||||
addCaretToUndo();
|
addCaretToUndo();
|
||||||
addSelectionToUndo();
|
addSelectionToUndo();
|
||||||
}
|
}
|
||||||
|
int origBlockBeginLine = selectionBeginLine();
|
||||||
|
int origBlockEndLine = selectionEndLine();
|
||||||
BufferCoord origBlockBegin = blockBegin();
|
BufferCoord origBlockBegin = blockBegin();
|
||||||
BufferCoord origBlockEnd = blockEnd();
|
BufferCoord origBlockEnd = blockEnd();
|
||||||
PCodeFoldingRange foldRange=foldStartAtLine(origBlockEnd.line);
|
|
||||||
|
PCodeFoldingRange foldRange=foldStartAtLine(origBlockEndLine);
|
||||||
if (foldRange && foldRange->collapsed)
|
if (foldRange && foldRange->collapsed)
|
||||||
return;
|
return;
|
||||||
// for (int line=origBlockBegin.Line;line<=origBlockEnd.Line;line++) {
|
// for (int line=origBlockBegin.Line;line<=origBlockEnd.Line;line++) {
|
||||||
|
@ -2173,16 +2176,16 @@ void QSynEdit::doMoveSelUp()
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Delete line above selection
|
// Delete line above selection
|
||||||
QString s = mDocument->getLine(origBlockBegin.line - 2); // before start, 0 based
|
QString s = mDocument->getLine(origBlockBeginLine - 2); // before start, 0 based
|
||||||
mDocument->deleteAt(origBlockBegin.line - 2); // before start, 0 based
|
mDocument->deleteAt(origBlockBeginLine - 2); // before start, 0 based
|
||||||
doLinesDeleted(origBlockBegin.line - 1, 1); // before start, 1 based
|
doLinesDeleted(origBlockBeginLine - 1, 1); // before start, 1 based
|
||||||
|
|
||||||
// Insert line below selection
|
// Insert line below selection
|
||||||
mDocument->insertLine(origBlockEnd.line - 1, s);
|
mDocument->insertLine(origBlockEndLine - 1, s);
|
||||||
doLinesInserted(origBlockEnd.line, 1);
|
doLinesInserted(origBlockEndLine, 1);
|
||||||
// Restore caret and selection
|
// Restore caret and selection
|
||||||
setCaretAndSelection(
|
setCaretAndSelection(
|
||||||
BufferCoord{mCaretX, origBlockBegin.line - 1},
|
BufferCoord{mCaretX, origBlockBeginLine - 1},
|
||||||
BufferCoord{origBlockBegin.ch, origBlockBegin.line - 1},
|
BufferCoord{origBlockBegin.ch, origBlockBegin.line - 1},
|
||||||
BufferCoord{origBlockEnd.ch, origBlockEnd.line - 1}
|
BufferCoord{origBlockEnd.ch, origBlockEnd.line - 1}
|
||||||
);
|
);
|
||||||
|
@ -2207,21 +2210,23 @@ void QSynEdit::doMoveSelDown()
|
||||||
addCaretToUndo();
|
addCaretToUndo();
|
||||||
addSelectionToUndo();
|
addSelectionToUndo();
|
||||||
}
|
}
|
||||||
|
int origBlockBeginLine = selectionBeginLine();
|
||||||
|
int origBlockEndLine = selectionEndLine();
|
||||||
BufferCoord origBlockBegin = blockBegin();
|
BufferCoord origBlockBegin = blockBegin();
|
||||||
BufferCoord origBlockEnd = blockEnd();
|
BufferCoord origBlockEnd = blockEnd();
|
||||||
|
|
||||||
PCodeFoldingRange foldRange=foldStartAtLine(origBlockEnd.line);
|
PCodeFoldingRange foldRange=foldStartAtLine(origBlockEndLine);
|
||||||
if (foldRange && foldRange->collapsed)
|
if (foldRange && foldRange->collapsed)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Delete line below selection
|
// Delete line below selection
|
||||||
QString s = mDocument->getLine(origBlockEnd.line); // after end, 0 based
|
QString s = mDocument->getLine(origBlockEndLine); // after end, 0 based
|
||||||
mDocument->deleteAt(origBlockEnd.line); // after end, 0 based
|
mDocument->deleteAt(origBlockEndLine); // after end, 0 based
|
||||||
doLinesDeleted(origBlockEnd.line, 1); // before start, 1 based
|
doLinesDeleted(origBlockEndLine, 1); // before start, 1 based
|
||||||
|
|
||||||
// Insert line above selection
|
// Insert line above selection
|
||||||
mDocument->insertLine(origBlockBegin.line - 1, s);
|
mDocument->insertLine(origBlockBeginLine - 1, s);
|
||||||
doLinesInserted(origBlockBegin.line, 1);
|
doLinesInserted(origBlockBeginLine , 1);
|
||||||
|
|
||||||
// Restore caret and selection
|
// Restore caret and selection
|
||||||
setCaretAndSelection(
|
setCaretAndSelection(
|
||||||
|
@ -6743,6 +6748,30 @@ BufferCoord QSynEdit::blockEnd() const
|
||||||
return mBlockEnd;
|
return mBlockEnd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int QSynEdit::selectionBeginLine() const
|
||||||
|
{
|
||||||
|
if (mActiveSelectionMode == SelectionMode::Column) {
|
||||||
|
return (mBlockBegin.line < mBlockEnd.line)? mBlockBegin.line : mBlockEnd.line;
|
||||||
|
} else {
|
||||||
|
return (mBlockBegin.line < mBlockEnd.line)? mBlockBegin.line : mBlockEnd.line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int QSynEdit::selectionEndLine() const
|
||||||
|
{
|
||||||
|
if (mActiveSelectionMode == SelectionMode::Column) {
|
||||||
|
return (mBlockBegin.line < mBlockEnd.line)? mBlockEnd.line : mBlockBegin.line;
|
||||||
|
} else {
|
||||||
|
if (mBlockBegin.line < mBlockEnd.line) {
|
||||||
|
return (mBlockEnd.ch==1)?mBlockEnd.line-1 : mBlockEnd.line;
|
||||||
|
} else if (mBlockBegin.line == mBlockEnd.line){
|
||||||
|
return mBlockBegin.line;
|
||||||
|
} else {
|
||||||
|
return (mBlockBegin.ch==1)?mBlockBegin.line-1 : mBlockBegin.line;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void QSynEdit::clearSelection()
|
void QSynEdit::clearSelection()
|
||||||
{
|
{
|
||||||
setActiveSelectionMode(SelectionMode::Normal);
|
setActiveSelectionMode(SelectionMode::Normal);
|
||||||
|
|
|
@ -320,6 +320,8 @@ public:
|
||||||
|
|
||||||
BufferCoord blockBegin() const;
|
BufferCoord blockBegin() const;
|
||||||
BufferCoord blockEnd() const;
|
BufferCoord blockEnd() const;
|
||||||
|
int selectionBeginLine() const;
|
||||||
|
int selectionEndLine() const;
|
||||||
|
|
||||||
void clearSelection();
|
void clearSelection();
|
||||||
void setBlockBegin(BufferCoord value);
|
void setBlockBegin(BufferCoord value);
|
||||||
|
|
Loading…
Reference in New Issue