Go to bug ID
Hello, guest. We have noticed that you are not registered at this bug tracker. Your experience will be greatly enhanced if you log in. To do so, you first must register by clicking on the Register tab at the top. If you are already registered, you can login at the Login tab.
Syndicate Syndicate Listing Display Search Login/Register
Bug Id ?
Reporter ?
GMontante
Product/Version ?
Crimson Editor / Version 3.72 (beta, prior to r241)
Status ?
Closed
Severity ?
Minor
Duplicate Of ?
- none -
Summary ?
When filename contains parenthesis, OutputWindow double-click fails to open file.
Report Time ?
January 12, 2008 09:44:12 PM
Assignment ?
- none -
Resolution ?
Fixed
Priority ?
Normal
Dependencies ?
- none -


Votes
For: 0 (0%)
Against: 0 (0%)
Total: 0

January 12, 2008 09:44:12 PM GMontante
After using "Search - Find in files...", if you double-click on an entry in the Output window (in order to open that file and jump to the line containing the search text), the file doesn't open if the filename contains a parenthesis.

After the original code, I've included a fix that I used in the old Crimson Editor.

The original code from version Crimson Editor 3.72 follows:
=============================================================================================================
void COutputWindow::OnDblclkOutput()
{
INT nSelect = m_lstConsoleOutput.GetCurSel();
if( nSelect == LB_ERR ) return;

CString szString; m_lstConsoleOutput.GetText(nSelect, szString);
if( ! szString.GetLength() ) return;

INT nIndex1 = szString.Find('('); if( nIndex1 < 0 ) return;
INT nIndex2 = szString.Find(')'); if( nIndex2 < 0 ) return;
if( nIndex2 < nIndex1 ) return;

CString szPathName = szString.Left(nIndex1);
if( ! VerifyFilePath(szPathName) ) return;

CString szLineNum = szString.Mid(nIndex1+1, nIndex2-nIndex1-1);
INT nLineNum = atoi(szLineNum); if( ! nLineNum ) return;

CCedtApp * pApp = (CCedtApp *)AfxGetApp(); if( ! pApp ) return;
pApp->PostOpenDocumentFile( szPathName, nLineNum );
}
=============================================================================================================

A code patch follows:
=============================================================================================================
This code supports double-clicking in the Output window on a line formatted as: filename (line_number).
It opens filename and jumps to the line_number. Original code failed when the filename, itself, contained parenthesis.

// Gary Montante 4/25/2007 2:09pm - szString.TrimLeft() in case error line indented
// Gary Montante 4/18/2007 4:41am - handle singleton parenthesis (left or right) in filename
// Gary Montante 3/01/2007 5:11am - take care of parentheses appearing in actual pathname (e.g., file(na)me (line))
void COutputWindow::OnDblclkOutput()
{
INT nSelect = m_lstConsoleOutput.GetCurSel();
if( nSelect == LB_ERR ) return;

CString szString; m_lstConsoleOutput.GetText(nSelect, szString);
szString.TrimLeft(" \\t");
if( ! szString.GetLength() ) return;

INT nIndex1 = 0, nIndex2, nIndexPrev = 0, nIndexLeft, nIndexRight;
bool gotFilename = false;
CString szPathName;
// name(line nr) ... Look for good filename and numeric text
// (warning: filename, itself, could contain parenthesis)
// Possibilites: (a) no parentheses set (thus, no line number);
// (b) got a parentheses set, but preceding text is NOT a valid filename
// or the set doesn't enclose numeric text
do
{
CString temp = szString.Mid(nIndex1);
nIndexLeft = temp.Find('('); if( nIndexLeft < 0 ) return; //look for left-paren of parentheses set
nIndexRight = temp.Find(')'); if( nIndexRight < 0 ) return; //look for right-paren of parentheses set
if( nIndexRight < nIndexLeft )
{ // oops, left/right mismatch: "...)...(..." situation
// right--^ ^--left
// ^--new nIndex1
nIndex1 = nIndex1+nIndexLeft; //continue searching for line number at left-paren
continue;
}
// Situation: could be "filename(stuff)...", or "no_name(stuff)..." [e.g., "fil(ename (line nr)"]
// Init nIndex1 to left-paren position, nIndex2 to right-paren position
nIndex2 = nIndex1+nIndexRight;
nIndex1 += nIndexLeft;
if( nIndex2 < nIndex1 ) return; // should be impossible...

//Test that we've got a filename before the parentheses set ["filename(stuff)"]
szPathName = szString.Left(nIndex1);
if( VerifyFilePath(szPathName) ) { gotFilename = true; break;}
nIndex1 +=1; //No filename before left-paren. Skip past it and continue looking.
}while( nIndex1 >= 0);
if( gotFilename == false )
return;

// We've got: ["filename(stuff)"] If stuff is numeric text, use it.
CString szLineNum = szString.Mid(nIndex1+1, nIndex2-nIndex1-1);
INT nLineNum = atoi(szLineNum); if( ! nLineNum ) return;

CCedtApp * pApp = (CCedtApp *)AfxGetApp(); if( ! pApp ) return;
pApp->PostOpenDocumentFile( szPathName, nLineNum );
}
=============================================================================================================


January 17, 2008 11:46:37 PM Phil
Confirmed. I'll test your code now.

Thanks,
Phil

January 18, 2008 12:31:52 AM Phil
Fixed now. Thanks.