Author Topic: WISH: Add "Skip inactive code" option in search options  (Read 7235 times)

Ding Zhaojie

  • Senior Community Member
  • Posts: 194
  • Hero Points: 37
WISH: Add "Skip inactive code" option in search options
« on: July 01, 2008, 02:59:57 AM »
The color coding search options in SE is great, but I missed a useful option in SourceInsight: Skip inactive code:

It is quit useful, because some coding rules such as MISRA C 98 suggest using #if 0 ... #endif to surround the unused codes. In SourceInsight, these codes will be displayed as dimmed "Inactive Code":

And if I checked "Skip Inactive Code" in search option, these codes will not be searched.

But in SE, I often get many results in these dead codes. I have to check them one by one, and the worse thing is: the inactive codes in SE just look like normal codes, sometimes I might made mistakes if the inactive codes contains too many lines. So I hope:
1. SE could dim the inactive codes just like the SourceInsight does (I think it is simple);
2. Add Skip Inactive Code option in color coding search options.
« Last Edit: July 08, 2008, 12:24:09 PM by Ding Zhaojie »

ScottW, VP of Dev

  • Senior Community Member
  • Posts: 1471
  • Hero Points: 64
Re: HOPE: Add "Skip inactive code" option in search options
« Reply #1 on: July 01, 2008, 08:59:58 PM »
I have filed a change request for this. No promises when it will be delivered, though.

jimlangrunner

  • Senior Community Member
  • Posts: 360
  • Hero Points: 31
  • Jim Lang - always a student.
Re: HOPE: Add "Skip inactive code" option in search options
« Reply #2 on: July 02, 2008, 11:48:50 AM »
It is quit useful, because some coding rules such as MISRA C 98 suggest using #if 0 ... #endif to surround the unused codes. In SourceInsight, these codes will be displayed as dimmed "Inactive Code":

Now I'm curious.  I don't do much C programming, and I haven't looked at it in quite a while.  Why would you surround inactive code thus?  Would commented-out code not serve the same purpose? 

I think, maybe, it might improve readability (code that's commented out looks like just so much comment space), but I don't know how useful that really is.  Is that it?

Thanks,
Jim.

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6884
  • Hero Points: 530
Re: HOPE: Add "Skip inactive code" option in search options
« Reply #3 on: July 03, 2008, 03:36:04 PM »
I like the inactive code color approach.

hs2

  • Senior Community Member
  • Posts: 2761
  • Hero Points: 292
Re: HOPE: Add "Skip inactive code" option in search options
« Reply #4 on: July 03, 2008, 04:05:07 PM »
Me too. HS2

chrisant

  • Senior Community Member
  • Posts: 1410
  • Hero Points: 131
Re: HOPE: Add "Skip inactive code" option in search options
« Reply #5 on: July 03, 2008, 08:52:23 PM »
Now I'm curious.  I don't do much C programming, and I haven't looked at it in quite a while.  Why would you surround inactive code thus?  Would commented-out code not serve the same purpose?

From my perspective here are some reasons why #if0 is preferable to commenting:
  • Commenting with // perturbs existing indentation; #if0 does not (using /**/ also does not).
  • Commenting with #if0 makes it easy to reactivate the code (change to #if1, or to #ifdef FOOBAR later, etc).
  • Some people (like myself) prefer to use comments for...well, comments.  Old code is not a comment, it doesn't explain something.  It is just old code.

With that said, I also don't like to see #if0 code stay around very long.  Once it is confirmed to be no longer needed, I prefer to see it removed.  If we ever need to get it back, we'll refer to the source control history.

Wanderer

  • Senior Community Member
  • Posts: 557
  • Hero Points: 23
Re: HOPE: Add "Skip inactive code" option in search options
« Reply #6 on: July 03, 2008, 09:32:02 PM »
Now I'm curious.  I don't do much C programming, and I haven't looked at it in quite a while.  Why would you surround inactive code thus?  Would commented-out code not serve the same purpose?

From my perspective here are some reasons why #if0 is preferable to commenting:
  • Commenting with // perturbs existing indentation; #if0 does not (using /**/ also does not).
  • Commenting with #if0 makes it easy to reactivate the code (change to #if1, or to #ifdef FOOBAR later, etc).
  • Some people (like myself) prefer to use comments for...well, comments.  Old code is not a comment, it doesn't explain something.  It is just old code.

With that said, I also don't like to see #if0 code stay around very long.  Once it is confirmed to be no longer needed, I prefer to see it removed.  If we ever need to get it back, we'll refer to the source control history.

In addition to everything chrisant said:
When changing a substantial block, I like #if/#else/#endif.  It keeps the original version in plain view for reference (but is easily hidden with Selective Display), and it is easy to toggle between the original implementation and the new implementation for testing.

jimlangrunner

  • Senior Community Member
  • Posts: 360
  • Hero Points: 31
  • Jim Lang - always a student.
Re: HOPE: Add "Skip inactive code" option in search options
« Reply #7 on: July 07, 2008, 11:33:50 AM »
Nice.  Thank you.  Now I wish every language supported #if 0...