Author Topic: Toggle comment  (Read 17348 times)

lfm

  • Guest
Toggle comment
« on: May 29, 2006, 02:17:45 pm »
There are some unicode string in my test application. I have  commented all code in main.cpp, then selected all code, when i  "Edit->Toggle comment", a error occured, look follows pictures:


[attachment deleted by admin]
« Last Edit: May 30, 2006, 03:17:04 am by lfm »

lfm

  • Guest
Re: Toggle comment
« Reply #1 on: May 30, 2006, 02:38:10 am »
I was disappointed , why nobody interested?

sethjackson

  • Guest
Re: Toggle comment
« Reply #2 on: May 30, 2006, 03:28:03 am »
I was disappointed , why nobody interested?

Well I for one am interested (and I'm pretty sure others are too).

Could you submit this bug to BerliOS?

lfm

  • Guest
Re: Toggle comment
« Reply #3 on: May 30, 2006, 03:56:02 am »
Well I for one am interested (and I'm pretty sure others are too).
Could you submit this bug to BerliOS?
Thank you! But my bad English... :oops:

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: Toggle comment
« Reply #4 on: May 30, 2006, 07:36:14 am »
a few questions :

1) when you report the bug : please add your little test project, containing the main.cpp we see in the screenshot
2) when that little unicode string is removed, does the bug still happen ???


lfm

  • Guest
Re: Toggle comment
« Reply #5 on: May 30, 2006, 08:26:35 am »
a few questions :
1) when you report the bug : please add your little test project, containing the main.cpp we see in the screenshot
2) when that little unicode string is removed, does the bug still happen ???
1. The project file had be added.
2. when that little unicode string is removed, the bug does not happen.

[attachment deleted by admin]

lfm

  • Guest
Re: Toggle comment
« Reply #6 on: June 01, 2006, 05:21:55 am »
Now ,i use rev 2516, but that problem still happen. My steps:
1. open the file that include unicode strings, There isn't comment in the file this time;
2. click "Edit->Select all", then click "Edit->Toggle comment", comment all in file ;
3. click "Edit->Select all", still click "Edit->Toggle comment", problem happen.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: Toggle comment
« Reply #7 on: June 01, 2006, 07:42:34 am »
Now ,i use rev 2516, but that problem still happen. My steps:
1. open the file that include unicode strings, There isn't comment in the file this time;
2. click "Edit->Select all", then click "Edit->Toggle comment", comment all in file ;
3. click "Edit->Select all", still click "Edit->Toggle comment", problem happen.

we are looking into it, we already narrowed the spot where it goes wrong, a little bit more investigation and hopefuly a solution ...

lfm

  • Guest
Re: Toggle comment
« Reply #8 on: June 12, 2006, 04:16:20 pm »
rev 2544, this problem still happen.

lfm

  • Guest
Re: Toggle comment
« Reply #9 on: June 26, 2006, 11:36:54 am »
Please attend to this problem.

sethjackson

  • Guest
Re: Toggle comment
« Reply #10 on: June 26, 2006, 09:47:06 pm »
Umm killerbot why doesn't this work (Yeah I know it has to do with Unicode)? The watches dialog shows square boxes for the Unicode characters. I think this problem happens in main.cpp around line 2205.......

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: Toggle comment
« Reply #11 on: June 26, 2006, 09:56:18 pm »
I have done some debugging once, and I felt like it was going wrong at :
               stc->ReplaceTarget( strLine );
(during uncomment).
Should check my notes again. I kind of had the impression it could be a wxScintilla problem...

sethjackson

  • Guest
Re: Toggle comment
« Reply #12 on: June 26, 2006, 09:59:28 pm »
I have done some debugging once, and I felt like it was going wrong at :
               stc->ReplaceTarget( strLine );
(during uncomment).
Should check my notes again. I kind of had the impression it could be a wxScintilla problem...

Hmm maybe wxScintilla has a problem with Unicode....... :(

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: Toggle comment
« Reply #13 on: June 28, 2006, 06:05:04 pm »
for those interested, attached zip file contains a simple main.cpp.
Put your cursor at the start of the (first) line and select the uncomment command --> you can see the problem ;-)

Here's a little modified part of the codfe from (the CB source that is) main.cpp::MainFrame::OnEditUncommentSelected()
In comments I have put the values from the debugger in the above example :

Code
int commentPos = strLine.Strip( wxString::leading ).Find( Comment );
if( commentPos ==0 )
{
// Uncomment
strLine.Replace( Comment, _T( "" ), false );

// Update
int start = stc->PositionFromLine( startLine );       // 0
stc->SetTargetStart( start );
// adjust for the '//' we erased
int x = strLine.Length();                                    // 18
int y = Comment.Length();                                // 2
stc->SetTargetEnd( start + strLine.Length() + Comment.Length() );  // 20
stc->ReplaceTarget( strLine );
}

These values seems correct, but after the stc->ReplaceTarget the damage is done.

I'll try to test if it works with the new wxScintilla, but I have already a workaround in mind which I am gonna try out first.

Note that "commenting" the line works, for that purpose stc->InsertText was used, and that seems to work well.

[attachment deleted by admin]

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: Toggle comment
« Reply #14 on: June 28, 2006, 06:13:38 pm »
allright my workaround works this is the same part of code, but with the fix : I will commit later this evening.
If you see troubles in the solution, feel free to post.

Code
int commentPos = strLine.Strip( wxString::leading ).Find( Comment );
if( commentPos ==0 )
{      // we know the comment is there (maybe preceded by white space)
int Pos = strLine.Find(Comment);
int start = stc->PositionFromLine( startLine ) + Pos;
int end = start + Comment.Length();
stc->SetTargetStart( start );
stc->SetTargetEnd( end );
stc->ReplaceTarget( wxEmptyString );
}

 :D :D :D :D :D :D


[EDIT] : And I will do the same thing in OnEditToggleCommentSelected ;-)
« Last Edit: June 28, 2006, 06:20:18 pm by killerbot »