| Summary: | problem with automaticly complete of \begin{env} | ||
|---|---|---|---|
| Product: | [Applications] kile | Reporter: | Ralf Butenuth <rbutenuth> |
| Component: | general | Assignee: | Jeroen Wijnhout <spam> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | CC: | thomas.braun |
| Priority: | NOR | ||
| Version First Reported In: | 1.8.1 | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
Hello, please try the newest version 1.9.2, 1.8 is pretty old. If you also have the problem with the newest version, I can have a look. Thanks Thomas Braun Thanks. Bug still exists in Kile 1.9.2 with KDE 3.5.2 on my machine. I can confirm that with Kile 1.8.1 KDE 3.5.4 in Kubuntu Dapper, \begin{env} does not autocomplete with \end{env} even if that box is checked in Kile settings.
I will wait for Edgy to see if it persists in the new kile.
SVN commit 605593 by tbraun:
BUG: 137131
BUG: 134793
Fix bug where environments were completed which should not have been completed.
Remove selected text in any case if the user insert "
M +22 -15 kileedit.cpp
--- trunk/extragear/office/kile/kile/kileedit.cpp #605592:605593
@@ -2292,7 +2292,9 @@
uint row,col;
view->cursorPositionReal(&row,&col);
Kate::Document *doc = view->getDoc();
-
+ if(doc)
+ doc->removeSelectedText();
+
// simply insert, if we are inside a verb command
if ( insideVerb(view) || insideVerbatim(view) )
{
@@ -2451,35 +2453,40 @@
bool EditorExtension::shouldCompleteEnv(const QString &env, Kate::View *view)
{
- kdDebug() << "===EditorExtension::shouldCompleteEnv(...)===" << endl;
- QString envname = env;
- envname.replace("*","\\*");
+ kdDebug() << "===EditorExtension::shouldCompleteEnv( " << env << " )===" << endl;
QRegExp reTestBegin,reTestEnd;
- if ( envname == "\\[" )
+ if ( env == "\\[" )
{
- reTestBegin.setPattern("\\\\\\[");
- reTestEnd.setPattern("\\\\\\]");
+ kdDebug() << "display style" << endl;
+ reTestBegin.setPattern("(?:[^\\\\]|^)\\\\\\[");
+ // the first part is a non-capturing bracket (?:...) and we check if we don't have a backslash in front,
+ // or that we are at the begin of the line
+ reTestEnd.setPattern("(?:[^\\\\]|^)\\\\\\]");
}
else
{
- reTestBegin.setPattern("\\\\begin\\s*\\{" + envname + "\\}");
- reTestEnd.setPattern("\\\\end\\s*\\{" + envname + "\\}");
+ reTestBegin.setPattern("(?:[^\\\\]|^)\\\\begin\\s*\\{" + QRegExp::escape(env) + "\\}");
+ reTestEnd.setPattern("(?:[^\\\\]|^)\\\\end\\s*\\{" + QRegExp::escape(env) + "\\}");
}
-
+
int num = view->getDoc()->numLines();
int numBeginsFound = 0;
int numEndsFound = 0;
uint realLine, realColumn;
- view->cursorPositionReal(&realLine, &realColumn);
+ view->cursorPositionReal(&realLine, &realColumn);
for ( int i = realLine; i < num; ++i)
{
numBeginsFound += view->getDoc()->textLine(i).contains(reTestBegin);
numEndsFound += view->getDoc()->textLine(i).contains(reTestEnd);
- if ( (numBeginsFound == 1) && (numEndsFound == 1) ) return false;
- else if ( (numEndsFound == 0) && (numBeginsFound > 1) ) return true;
- else if ( (numBeginsFound > 2) || (numEndsFound > 1) ) return true; //terminate the search
+ kdDebug() << "line is " << i << " numBeginsFound = " << numBeginsFound << " , " << "numEndsFound = " << numEndsFound << endl;
+ if ( numEndsFound >= numBeginsFound )
+ return false;
+ else if ( numEndsFound == 0 && numBeginsFound > 1 )
+ return true;
+ else if ( numBeginsFound > 2 || numEndsFound > 1 )
+ return true; // terminate the search
}
-
+
return true;
}
Thanks a lot Thomas for fixing that bug. It now workes perfectly from Kile 1.9.3 on. |
Version: 1.8.1 (using KDE 3.5.2, Kubuntu Package 4:3.5.2-0ubuntu18.1 dapper) Compiler: Target: i486-linux-gnu OS: Linux (i686) release 2.6.15-27-686 Kile produces a wrong auto-completition if I have two \begin{env} -Statements in one line! Example: If i have the following code: Let \begin{env} foo \end{env} and \begin{env} bar \end{env} and hit enter at the end of the line, it makes an third \end{env} appear below the second \begin{env}. Quit annoying. Thanks, Ralf