Skip to content

Commit 7b2c945

Browse files
committed
Remove jedi-completor because it crashed the app
Signed-off-by: JaDogg <[email protected]>
1 parent 1732960 commit 7b2c945

File tree

2 files changed

+12
-49
lines changed

2 files changed

+12
-49
lines changed

CodeEditor/codeeditor.cpp

Lines changed: 10 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <QTextStream>
4646
#include "CodeEditor/codeeditor.h"
4747

48-
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent), m_completer(0), m_jediCompleter(0) {
48+
CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent), m_completer(nullptr), m_jediCompleter(nullptr) {
4949
lineNumberArea = new LineNumberArea(this);
5050

5151
connect(this, SIGNAL(blockCountChanged(int)), this,
@@ -63,7 +63,7 @@ CodeEditor::CodeEditor(QWidget *parent) : QPlainTextEdit(parent), m_completer(0)
6363

6464
void CodeEditor::setCompleter(QCompleter *completer) {
6565
if (m_completer)
66-
QObject::disconnect(m_completer, nullptr, this, 0);
66+
QObject::disconnect(m_completer, nullptr, this, nullptr);
6767

6868
m_completer = completer;
6969

@@ -77,7 +77,7 @@ void CodeEditor::setCompleter(QCompleter *completer) {
7777

7878
void CodeEditor::setJediCompleter(QCompleter *jediCompleter, const QString& getJediCode) {
7979
if (m_jediCompleter) {
80-
QObject::disconnect(m_jediCompleter, 0, this, 0);
80+
QObject::disconnect(m_jediCompleter, nullptr, this, nullptr);
8181
} else {
8282
m_jedi = new Jedi(this);
8383
m_jedi->SetJediGetCode(QString(getJediCode.toStdString().c_str()));
@@ -223,22 +223,7 @@ void CodeEditor::keyPressEvent(QKeyEvent *e) {
223223

224224
bool no_process = false;
225225

226-
if (m_jediCompleter && m_completer && m_jediCompleter->popup()->isVisible() && m_completer->popup()->isVisible()) {
227-
m_jediCompleter->popup()->hide();
228-
e->ignore();
229-
return;
230-
} else if (m_jediCompleter && m_jediCompleter->popup()->isVisible()) {
231-
// The following keys are forwarded by the completer to the widget
232-
switch (e->key()) {
233-
case Qt::Key_Escape:
234-
case Qt::Key_Tab:
235-
case Qt::Key_Backtab:
236-
e->ignore();
237-
return; // let the completer do default behavior
238-
default:
239-
break;
240-
}
241-
} else if (m_completer && m_completer->popup()->isVisible()) {
226+
if (m_completer && m_completer->popup()->isVisible()) {
242227
// The following keys are forwarded by the completer to the widget
243228
switch (e->key()) {
244229
case Qt::Key_Escape:
@@ -301,15 +286,14 @@ void CodeEditor::keyPressEvent(QKeyEvent *e) {
301286
// CTRL+Space
302287
bool ctrlSpace = ((e->modifiers() & Qt::ControlModifier) &&
303288
e->key() == Qt::Key_Space);
304-
if ((!m_jediCompleter || !ctrlSpace) && !no_process)
289+
if (!ctrlSpace && !no_process)
305290
QPlainTextEdit::keyPressEvent(e);
306291

307292
const bool ctrlOrShift =
308293
e->modifiers() & (Qt::ControlModifier | Qt::ShiftModifier);
309294

310-
// Do nothing If it's just ctrl or shift, or completer or jedi isn't there
311-
// If it is ctrl or shift we don't need to hide the auto complete
312-
if (!m_jediCompleter || !m_completer || (ctrlOrShift && e->text().isEmpty())) {
295+
296+
if (!m_completer || (ctrlOrShift && e->text().isEmpty())) {
313297
return;
314298
}
315299

@@ -321,15 +305,9 @@ void CodeEditor::keyPressEvent(QKeyEvent *e) {
321305
if (!ctrlSpace &&
322306
(hasModifier || e->text().isEmpty() || completionPrefix.length() < 2)) {
323307
m_completer->popup()->hide();
324-
m_jediCompleter->popup()->hide();
325308
return;
326309
}
327310

328-
if (ctrlSpace && completionPrefix != m_jediCompleter->completionPrefix()) {
329-
// Now is the time to populate jedi
330-
m_jediCompleter->setCompletionPrefix(completionPrefix);
331-
m_jediCompleter->popup()->setCurrentIndex(m_completer->completionModel()->index(0, 0));
332-
}
333311
if (completionPrefix != m_completer->completionPrefix()) {
334312
m_completer->setCompletionPrefix(completionPrefix);
335313
m_completer->popup()->setCurrentIndex(m_completer->completionModel()->index(0, 0));
@@ -338,21 +316,6 @@ void CodeEditor::keyPressEvent(QKeyEvent *e) {
338316
QRect cr = cursorRect();
339317
cr.setWidth(m_completer->popup()->sizeHintForColumn(0) +
340318
m_completer->popup()->verticalScrollBar()->sizeHint().width());
341-
m_completer->popup()->hide();
342-
m_jediCompleter->popup()->hide();
343-
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
344-
int row = this->textCursor().blockNumber();
345-
int col = this->textCursor().positionInBlock();
346-
QStringList words = m_jedi->AutoComplete(this->toPlainText(), row, col);
347-
QStringListModel *updatedJedi = new QStringListModel(words, m_jedi);
348-
m_jediCompleter->setModel(updatedJedi);
349-
QApplication::restoreOverrideCursor();
350-
m_jediCompleter->complete(cr);
351-
} else {
352-
QRect cr = cursorRect();
353-
cr.setWidth(m_completer->popup()->sizeHintForColumn(0) +
354-
m_completer->popup()->verticalScrollBar()->sizeHint().width());
355-
m_jediCompleter->popup()->hide();
356319
m_completer->complete(cr);
357320
}
358321
}
@@ -363,8 +326,8 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) {
363326

364327
QTextBlock block = firstVisibleBlock();
365328
int blockNumber = block.blockNumber();
366-
int top = (int)blockBoundingGeometry(block).translated(contentOffset()).top();
367-
int bottom = top + (int)blockBoundingRect(block).height();
329+
int top = static_cast<int>(blockBoundingGeometry(block).translated(contentOffset()).top());
330+
int bottom = top + static_cast<int>(blockBoundingRect(block).height());
368331

369332
while (block.isValid() && top <= event->rect().bottom()) {
370333
if (block.isVisible() && bottom >= event->rect().top()) {
@@ -376,7 +339,7 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event) {
376339

377340
block = block.next();
378341
top = bottom;
379-
bottom = top + (int)blockBoundingRect(block).height();
342+
bottom = top + static_cast<int>(blockBoundingRect(block).height());
380343
++blockNumber;
381344
}
382345
}

CodeEditor/pythonsyntaxhighlighter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
* -----------Modified By Bhathiya Perera-------------
3434
*/
3535

36-
#include "CodeEditor/PythonSyntaxHighlighter.h"
36+
#include "CodeEditor/pythonsyntaxhighlighter.h"
3737

3838
PythonSyntaxHighlighter::PythonSyntaxHighlighter(QTextDocument *parent)
3939
: QSyntaxHighlighter(parent) {
@@ -260,7 +260,7 @@ PythonSyntaxHighlighter::PythonSyntaxHighlighter(QTextDocument *parent)
260260

261261
void PythonSyntaxHighlighter::setStyles() {
262262
basicStyles.insert("keyword", getTextCharFormat("orange", "bold"));
263-
basicStyles.insert("operator", getTextCharFormat("yellow", "bold"));
263+
basicStyles.insert("operator", getTextCharFormat("purple", "bold"));
264264
basicStyles.insert("builtins", getTextCharFormat("lightblue", "underline"));
265265
basicStyles.insert("brace", getTextCharFormat("red", "bold"));
266266
basicStyles.insert("string", getTextCharFormat("magenta"));

0 commit comments

Comments
 (0)