Bug 130148

Summary: Completion of citations broken if numbers/dots used
Product: [Applications] kile Reporter: Dominic Battre <dominic>
Component: generalAssignee: Jeroen Wijnhout <spam>
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Gentoo Packages   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: Fixes the completion of bibtex citations with numbers and dots

Description Dominic Battre 2006-07-02 14:48:28 UTC
Version:           1.9.1 (using KDE KDE 3.5.3)
Installed from:    Gentoo Packages

If your bibtex labels contain numbers and dots, the completion of citations is broken.

e.g. type \cite{<ENTER>db.p2p.h<ENTER> for db.p2p.heine.2006.infoscale I get the following debug output:

kile: ==CodeCompletion::completeWord()=========
kile: ==CodeCompletion::completeWord(d)=========
kile: ==CodeCompletion::completeWord(db)=========
kile: ==CodeCompletion::completeWord(p)=========
kile: ==CodeCompletion::completeWord(p2)=========
kile: ==CodeCompletion::completeWord(p2p)=========
kile: ==CodeCompletion::completeWord(h)=========

and the editor creates this reference:

\cite{db.p2p.hb.p2p.heine.2006.infoscale}

The attached patch fixes the problem.
Comment 1 Dominic Battre 2006-07-02 14:50:07 UTC
Created attachment 16855 [details]
Fixes the completion of bibtex citations with numbers and dots
Comment 2 Dominic Battre 2006-07-02 22:56:41 UTC
I just realized that _ is another perferctly legal and common character.  It should be easy to adapt the patch.  But make sure not to use isPuctuation, because that breaks \cite{foo,bar}.
Comment 3 Jeroen Wijnhout 2006-07-03 20:41:48 UTC
Thanks for the patch. I've tested it and it indeed fixes the bug (of which I was unaware)! After some more testing I will commit it.

best,
Jeroen
Comment 4 Thomas Braun 2006-09-03 15:25:59 UTC
SVN commit 580408 by tbraun:

BUG: 130148

patch already commited to the 1.9 branch,
patch by Dominic Battre


 M  +2 -2      codecompletion.cpp  


--- trunk/extragear/office/kile/kile/codecompletion.cpp #580407:580408
@@ -45,7 +45,7 @@
 	static QRegExp::QRegExp reRefExt;
 	static QRegExp::QRegExp reCite;
 	static QRegExp::QRegExp reCiteExt;
-	static QRegExp::QRegExp reNotRefChars("[^a-zA-z0-9_@\\+\\-\\*\\:]");
+	static QRegExp::QRegExp reNotRefChars("[^a-zA-z0-9_@\\.\\+\\-\\*\\:]");
 	
 	CodeCompletion::CodeCompletion(KileInfo *info) : m_ki(info), m_view(0L)
 	{
@@ -1096,7 +1096,7 @@
 			// get current character
 			ch = textline.at( index );
 
-			if ( ch.isLetter() || ( latexmode && ( index + 1 == ( int ) col ) && ch == '{' ) )
+			if ( ch.isLetter() || ch=='.' || ch == '_' || ch.isDigit() || ( latexmode && ( index + 1 == ( int ) col ) && ch == '{' ) )
 				++n;                           // accept letters and '{' as first character in latexmode
 			else
 			{