NO

Author Topic: Bug in Comment / Uncomment functionality  (Read 2924 times)

skirby

  • Guest
Bug in Comment / Uncomment functionality
« on: January 11, 2007, 12:33:21 PM »
Hello Pelle,

There is a bug in Comment and Uncomment functionnality.

Paste this piece of code:
Code: [Select]
int main(int argc, char *argv[])
{
    printf("The Begining\n");
    for (i = 0; i < 10; i++) {
        // Comment
        printf("i : %d", i);
    }
    printf("The End!\n");

    return 0;
}


Now select text from "The Begining" to "The End" and Comment the selected text.
You should have:
Code: [Select]
int main(int argc, char *argv[])
{
    // printf("The Begining\n");
    // for (i = 0; i < 10; i++) {
        // Comment                     => No comment has been added
        // printf("i : %d", i);
    // }
    // printf("The End!\n");

    return 0;
}


Now uncomment the same block.
You should have:
Code: [Select]
int main(int argc, char *argv[])
{
    printf("The Begining\n");
    for (i = 0; i < 10; i++) {
        Comment                     => The comment has disappeared
        printf("i : %d", i);
    }
    printf("The End!\n");

    return 0;
}

Could you correct this bug.

Thank you and have a nice day.

Offline Pelle

  • Administrator
  • Member
  • *****
  • Posts: 2266
    • http://www.smorgasbordet.com
Bug in Comment / Uncomment functionality
« Reply #1 on: January 11, 2007, 03:57:56 PM »
It's actually designed this way, so I will not classify it as a bug. Perhaps change the behaviour, but there are some reasons for this... (I think...)

Maybe. I will think about it...
/Pelle

skirby

  • Guest
Bug in Comment / Uncomment functionality
« Reply #2 on: January 11, 2007, 04:23:28 PM »
It is a strange behavior in my opinion.
It should be more logical (always in my opinion) to comment the block like this
Code: [Select]

int main(int argc, char *argv[])
{
//    printf("The Begining\n");
//    for (i = 0; i < 10; i++) {
//        // Comment
//        printf("i : %d", i);
//    }
//    printf("The End!\n");

    return 0;
}


Like that, if you have to uncomment the block, you simply have to delete all //

Don't you think it would be better like that?

ivanhv

  • Guest
Bug in Comment / Uncomment functionality
« Reply #3 on: January 11, 2007, 09:08:54 PM »
This last is the way Microsoft Visual Studio does it.

I agree with this form of comments. When you comment out something that is already slashed, comments should double (just add two bars at the beginning and be careless about the current contents of the line).

I think it's all about what you are customed to, but not putting in slashes when they already exist, can produce wrong code when you get slashes out; double comments are harmless.