- fix: error when delete contents in column mode on lines that has wide-chars

- fix: error when create folder in files view
This commit is contained in:
Roy Qu 2022-03-15 15:34:34 +08:00
parent 469c5f21d3
commit 021880b746
4 changed files with 303 additions and 295 deletions

View File

@ -21,6 +21,8 @@ Red Panda C++ Version 1.0.0
- fix: correctly reset caret when redo cut with no selection
- enhancement: close editor when middle button clicked on it's title tab
- fix: error when insert text in column mode
- fix: error when delete contents in column mode on lines that has wide-chars
- fix: error when create folder in files view
Red Panda C++ Version 0.14.5
- fix: the "gnu c++ 20" option in compiler set options is wrong

File diff suppressed because it is too large Load Diff

View File

@ -3595,11 +3595,13 @@ void MainWindow::onFilesViewCreateFolder()
{
QModelIndex index = ui->treeFiles->currentIndex();
QDir dir;
if (index.isValid()) {
if (index.isValid()
&& ui->treeFiles->selectionModel()->isSelected(index)) {
if (mFileSystemModel.isDir(index))
dir = QDir(mFileSystemModel.fileInfo(index).absoluteFilePath());
else
dir = mFileSystemModel.fileInfo(index).absoluteDir();
ui->treeFiles->expand(index);
} else {
dir = mFileSystemModel.rootDirectory();
}
@ -3607,9 +3609,9 @@ void MainWindow::onFilesViewCreateFolder()
int count = 0;
while (dir.exists(folderName)) {
count++;
folderName = tr("New Folder").arg(count);
folderName = tr("New Folder %1").arg(count);
}
mFileSystemModel.mkdir(index,folderName);
dir.mkdir(dir.filePath(folderName));
}
void MainWindow::onFilesViewRemoveFiles()

View File

@ -5324,65 +5324,65 @@ int SynEdit::insertTextByNormalMode(const QString &Value)
return Result;
}
int SynEdit::insertTextByColumnMode(const QString &Value, bool AddToUndoList)
int SynEdit::insertTextByColumnMode(const QString &value, bool addToUndoList)
{
QString Str;
QString TempString;
int Start;
int P;
int Len;
int InsertCol;
BufferCoord LineBreakPos;
int Result = 0;
QString str;
QString tempString;
int start;
int p;
int len;
int insertCol;
BufferCoord lineBreakPos;
int result = 0;
// Insert string at current position
InsertCol = charToColumn(mCaretY,mCaretX);
Start = 0;
insertCol = charToColumn(mCaretY,mCaretX);
start = 0;
do {
P = GetEOL(Value,Start);
if (P != Start) {
Str = Value.mid(Start,P-Start);
p = GetEOL(value,start);
if (p != start) {
str = value.mid(start,p-start);
// Move(Start^, Str[1], P - Start);
if (mCaretY > mLines->count()) {
Result++;
TempString = QString(InsertCol - 1,' ') + Str;
result++;
tempString = QString(insertCol - 1,' ') + str;
mLines->add("");
if (AddToUndoList) {
LineBreakPos.Line = mCaretY - 1;
LineBreakPos.Char = mLines->getString(mCaretY - 2).length() + 1;
if (addToUndoList) {
lineBreakPos.Line = mCaretY - 1;
lineBreakPos.Char = mLines->getString(mCaretY - 2).length() + 1;
mUndoList->AddChange(SynChangeReason::crLineBreak,
LineBreakPos,
LineBreakPos,
lineBreakPos,
lineBreakPos,
"", SynSelectionMode::smNormal);
}
} else {
TempString = mLines->getString(mCaretY - 1);
Len = stringColumns(TempString,0);
if (Len < InsertCol) {
TempString = TempString + QString(InsertCol - Len - 1,' ') + Str;
tempString = mLines->getString(mCaretY - 1);
len = stringColumns(tempString,0);
if (len < insertCol) {
tempString = tempString + QString(insertCol - len - 1,' ') + str;
} else {
int insertPos = charToColumn(TempString,InsertCol);
TempString.insert(insertPos-1,Str);
int insertPos = columnToChar(mCaretY,insertCol);
tempString.insert(insertPos-1,str);
}
}
properSetLine(mCaretY - 1, TempString);
properSetLine(mCaretY - 1, tempString);
// Add undo change here from PasteFromClipboard
if (AddToUndoList) {
if (addToUndoList) {
mUndoList->AddChange(SynChangeReason::crPaste, BufferCoord{mCaretX, mCaretY},
BufferCoord{mCaretX + (P - Start), mCaretY}, "", mActiveSelectionMode);
BufferCoord{mCaretX + (p - start), mCaretY}, "", mActiveSelectionMode);
}
}
if (P<Value.length() && ((Value[P]=='\r') || (Value[P]=='\n'))) {
P++;
if (P<Value.length() && Value[P]=='\n')
P++;
if (p<value.length() && ((value[p]=='\r') || (value[p]=='\n'))) {
p++;
if (p<value.length() && value[p]=='\n')
p++;
mCaretY++;
mStatusChanges.setFlag(SynStatusChange::scCaretY);
}
Start = P;
} while (P<Value.length());
mCaretX+=Str.length();
start = p;
} while (p<value.length());
mCaretX+=str.length();
mStatusChanges.setFlag(SynStatusChange::scCaretX);
return Result;
return result;
}
int SynEdit::insertTextByLineMode(const QString &Value)