Show no autocomplete popup after evaluate

Issue #46 closed
Former user created an issue

Originally reported on Google Code with ID 46

it is annoying when the last item in the editor contains something that
triggers the autocompletion. when you evaluate, the textChanged event
triggers, because in returnPressed, we use d->editor->setText() so the
autocomplete triggers. Simple solution is to disable autocompletion at
beginning of function and restore it then afterwards.

This is the function I changed in crunch.cpp


void Crunch::returnPressed()
{
  bool bAutoCompletion = d->editor->autoCompleteEnabled();
  d->editor->setAutoCompleteEnabled(false);

  QString str = Evaluator::autoFix( d->editor->text(),
Settings::self()->decimalPoint );
  if( str.isEmpty() )
  {
      d->editor->setAutoCompleteEnabled(bAutoCompletion);
      return;       
  }

  d->eval->setExpression( str );
  d->editor->appendHistory( str );
  d->historyDock->setHistory( d->editor->history() );

  HNumber result = d->eval->eval();
  if( !d->eval->error().isEmpty() )
    d->result->appendError( str, tr( "Error: %1" ).arg( d->eval->error() )  );
  else
  {
    d->result->append( str, result );
    d->editor->setAnsAvailable( true );
    d->variablesDock->updateList( d->eval );
  }

  d->editor->setText( str );
  d->editor->selectAll();
  d->editor->stopAutoCalc();
  d->autoAns = true;

  d->editor->setAutoCompleteEnabled(bAutoCompletion);  

  QTimer::singleShot( 0, d->editor, SLOT(setFocus()) );

  if( !isActiveWindow () )
    activateWindow();
}

Reported by deblauwetom on 2007-06-01 07:51:26

Comments (8)

  1. Former user Account Deleted

    ``` Could you kindly describe step-by-step on how to reproduce this?

    In theory, this should not happen because the editor has the stopAutoCalc() function. So perhaps we miss something here. ```

    Reported by `ariya.hidayat` on 2007-06-12 07:58:44 - Labels added: Milestone-0.8

  2. Former user Account Deleted

    ``` Hello,

    The problem is: the textchanged slot is triggered, because you use d->editor->setText I think. ```

    Reported by `deblauwetom` on 2007-06-12 08:22:15

  3. Former user Account Deleted

    ``` Yes, but the stopAutoCalc() should stop it.

    I try to reproduce it, but I can't. Could you give me an example of an expression which causes this problem? Perhaps I am missing something here. ```

    Reported by `ariya.hidayat` on 2007-06-12 08:26:22

  4. Former user Account Deleted

    ``` so the simulation is for example: t = 3<enter> 6 * t<the popup shows><enter or escape to clear it><enter to evaluate> <the popup shows again!> ```

    Reported by `deblauwetom` on 2007-06-12 08:26:41

  5. Former user Account Deleted

    ``` isn't the problem that you stop the autocalc, but not the autocomplete? ```

    Reported by `deblauwetom` on 2007-06-12 08:32:40

  6. Former user Account Deleted

    ``` OK, now I see why I understood it wrongly.

    I just commit the fix by adding stopAutoComplete() to the editor.

    Thanks a lot ! ```

    Reported by `ariya.hidayat` on 2007-06-12 08:47:49 - Status changed: `Fixed`

  7. Log in to comment