Author Topic: WISH: Add "Skip inactive code" option in search options  (Read 5898 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: 5768
  • Hero Points: 460
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: 2752
  • Hero Points: 291
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...