- fix: toggle block comment/delete to word begin/delete to word end are not correctly disabled when editor not open

This commit is contained in:
Roy Qu 2022-10-18 19:09:46 +08:00
parent 0c305272c0
commit 29da40bb14
6 changed files with 22 additions and 18 deletions

View File

@ -28,7 +28,7 @@ Red Panda C++ Version 1.5
- fix: editor tooltip for #include_next is not correctly calculated
- fix: ctrl+click on #include_next header name doesn't open the right file
- enhancement: parser used for non-project C files won't find header files in C++ include folders.
- fix: when physical memory is less than 16G or "Auto clearn
- fix: toggle block comment/delete to word begin/delete to word end are not correctly disabled when editor not open
Red Panda C++ Version 1.4

View File

@ -1209,10 +1209,10 @@ void Editor::mouseReleaseEvent(QMouseEvent *event)
QString s = document()->getString(p.line - 1);
if (mParser->isIncludeNextLine(s)) {
QString filename = mParser->getHeaderFileName(mFilename,s, true);
pMainWindow->openFile(filename,true);
pMainWindow->openFile(filename);
} if (mParser->isIncludeLine(s)) {
QString filename = mParser->getHeaderFileName(mFilename,s);
pMainWindow->openFile(filename,true);
pMainWindow->openFile(filename);
} else {
gotoDefinition(p);
return;
@ -3983,7 +3983,10 @@ void Editor::gotoDeclaration(const QSynedit::BufferCoord &pos)
filename = statement->fileName;
line = statement->line;
}
pMainWindow->openFile(filename);
Editor *e = pMainWindow->openFile(filename);
if (e) {
e->setCaretPositionAndActivate(line,1);
}
}
void Editor::gotoDefinition(const QSynedit::BufferCoord &pos)
@ -4009,7 +4012,10 @@ void Editor::gotoDefinition(const QSynedit::BufferCoord &pos)
filename = statement->definitionFileName;
line = statement->definitionLine;
}
pMainWindow->openFile(filename);
Editor *e = pMainWindow->openFile(filename);
if (e) {
e->setCaretPositionAndActivate(line,1);
}
}
QString getWordAtPosition(QSynedit::SynEdit *editor, const QSynedit::BufferCoord &p, QSynedit::BufferCoord &pWordBegin, QSynedit::BufferCoord &pWordEnd, Editor::WordPurpose purpose)

View File

@ -490,6 +490,7 @@ void MainWindow::updateEditorActions()
ui->actionPrint->setEnabled(false);
ui->actionSelectAll->setEnabled(false);
ui->actionToggleComment->setEnabled(false);
ui->actionToggle_Block_Comment->setEnabled(false);
ui->actionUnIndent->setEnabled(false);
ui->actionUndo->setEnabled(false);
ui->actionUnfoldAll->setEnabled(false);
@ -498,6 +499,9 @@ void MainWindow::updateEditorActions()
ui->actionDuplicate_Line->setEnabled(false);
ui->actionDelete_to_BOL->setEnabled(false);
ui->actionDelete_to_EOL->setEnabled(false);
ui->actionDelete_to_Word_End->setEnabled(false);
ui->actionDelete_Last_Word->setEnabled(false);
ui->actionFind->setEnabled(false);
ui->actionReplace->setEnabled(false);
@ -542,6 +546,7 @@ void MainWindow::updateEditorActions()
ui->actionPrint->setEnabled(true);
ui->actionSelectAll->setEnabled(e->document()->count()>0);
ui->actionToggleComment->setEnabled(!e->readOnly() && e->document()->count()>0);
ui->actionToggle_Block_Comment->setEnabled(!e->readOnly() && e->selAvail());
ui->actionUnIndent->setEnabled(!e->readOnly() && e->document()->count()>0);
ui->actionUnfoldAll->setEnabled(e->document()->count()>0);
ui->actionDelete_Line->setEnabled(!e->readOnly() && e->document()->count()>0);
@ -549,6 +554,9 @@ void MainWindow::updateEditorActions()
ui->actionDuplicate_Line->setEnabled(!e->readOnly() && e->document()->count()>0);
ui->actionDelete_to_BOL->setEnabled(!e->readOnly() && e->document()->count()>0);
ui->actionDelete_to_EOL->setEnabled(!e->readOnly() && e->document()->count()>0);
ui->actionDelete_to_Word_End->setEnabled(!e->readOnly() && e->document()->count()>0);
ui->actionDelete_Last_Word->setEnabled(!e->readOnly() && e->document()->count()>0);
ui->actionFind->setEnabled(true);
ui->actionReplace->setEnabled(true);

View File

@ -974,10 +974,9 @@ void CppParser::resetParser()
mBlockEndSkips.clear(); //list of for/catch block end token index;
mInlineNamespaceEndSkips.clear(); // list for inline namespace end token index;
mFilesToScan.clear(); // list of base files to scan
mNamespaces.clear(); //TStringList<String,List<Statement>> namespace and the statements in its scope
mNamespaces.clear(); // namespace and the statements in its scope
mInlineNamespaces.clear();
// We haven't scanned anything anymore
mPreprocessor = std::make_shared<CppPreprocessor>();
mTokenizer.reset();

View File

@ -536,7 +536,6 @@ private:
CppTokenizer mTokenizer;
PCppPreprocessor mPreprocessor;
//{ List of current project's file }
QSet<QString> mProjectFiles;
QVector<int> mBlockBeginSkips; //list of for/catch block begin token index;
QVector<int> mBlockEndSkips; //list of for/catch block end token index;
@ -547,12 +546,10 @@ private:
bool mParseLocalHeaders;
bool mParseGlobalHeaders;
bool mIsProjectFile;
//fMacroDefines : TList;
int mLockCount; // lock(don't reparse) when we need to find statements in a batch
bool mParsing;
QHash<QString,PStatementList> mNamespaces; //TStringList<String,List<Statement>> namespace and the statements in its scope
QHash<QString,PStatementList> mNamespaces; // namespace and the statements in its scope
QSet<QString> mInlineNamespaces;
//fRemovedStatements: THashedStringList; //THashedStringList<String,PRemovedStatements>
QMutex mMutex;
GetFileStreamCallBack mOnGetFileStream;

View File

@ -371,12 +371,6 @@ QString CppPreprocessor::getNextPreprocessor()
return result;
}
void CppPreprocessor::simplify(QString &output)
{
// Remove #
output = output.mid(1).trimmed();
}
void CppPreprocessor::handleBranch(const QString &line)
{
if (line.startsWith("ifdef")) {
@ -1143,7 +1137,7 @@ void CppPreprocessor::preprocessBuffer()
do {
s = getNextPreprocessor();
if (s.startsWith('#')) {
simplify(s);
s = s.mid(1).trimmed(); // remove #
if (!s.isEmpty()) {
handlePreprocessor(s);
}