Author Topic: Find in "Current Procedure" does not wrap (C language)  (Read 1937 times)

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Find in "Current Procedure" does not wrap (C language)
« on: August 24, 2016, 03:43:48 pm »
I am using the traditional find dialog. I have "Look in:" set to "Current Procedure". I have "LIst all occurrence" and "wrap at beginning/end" checked. Funny thing is that "wrap at beginning/end" is greyed out.

If I have the cursor in the middle of a C function and search for a local variable name, it is only finding the instances that are below the cursor location. I want to find all instances in the function, not just the ones below the current cursor location, but also above it until the function definition. I thought that was what "Wrap at beginning/end" is for? But I have "wrap at beginning/end" checked, but for some odd reason it is also greyed out. It seems to get ungreyed when I uncheck "List all occurrences".

I am using beta3 on linux

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1190
  • Hero Points: 115
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #1 on: August 24, 2016, 04:18:19 pm »
Wrap is disabled when using List all occurrences by design.  Wrapping flags are not used for List all occurrences, it searches the entire range selected in the Look in field.  The cursor location should not affect the results returned.  I am not seeing any issues with beta 3 in my tests, could you provide more info?

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #2 on: August 24, 2016, 04:21:30 pm »
The code is proprietary, I cannot share it. I've given all the info I can without sharing the code. I'll try to work on providing a test case if I have time.

Perhaps if I give you my configuration you could reproduce the issue? What can I do without sharing the code to get the issue reproduced by you?

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #3 on: August 24, 2016, 04:24:14 pm »
Here is a screenshot of my find dialog, maybe it helps you to reproduce?

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #4 on: August 24, 2016, 04:27:09 pm »
Here is another screenshot with a snippet of the code.

You can see that it missed finding the occurrences of dci_data_ptr on lines 1225 and 1231

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #5 on: August 24, 2016, 06:37:02 pm »
I uploaded a file "test2.c" to support.slickedit.com

There are some settings in my configuration that you should also set.

First, I have macro variable, defs_ctags_flag set to 10. See https://community.slickedit.com/index.php/topic,13290.msg52650.html#msg52650 for more details about that.

Also, in my preprocessor configuration, I have the following 3 set as "undef":

HOST
LTE_FRAME_TYPE_2
METRO_2x2

To reproduce, go to line 399. Search for "dci_data_ptr" using "Look in:" as "Current Procedure", and check "List all occurrences"

You will see that only the instances after line 399 are found, others above it are not found.

SE does seem to know the function boundaries. If you go to line 1780 (closing brace of function), and press Ctrl+], then it correctly finds the start of the function.

Lee

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 1190
  • Hero Points: 115
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #6 on: August 24, 2016, 07:15:44 pm »
Try this: from the same location in the file as you are searching, then Edit > Select > Procedure?  Does the entire procedure get selected as expected?   If the select-proc command fails, that might explain the results you are getting.  Could be an issue with preprocessing that is causing the parser to fail to detect the procedure boundaries. 

Thanks for the sample, I am able to replicate this in Beta 3 release.  I did just test this with all the latest fixes for next build, and it appears to be fixed there once I added the preprocessing undef's you listed.  There is a good chance this has already been addressed in one of the tagging fixes prepared for the next release.

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #7 on: August 24, 2016, 08:10:52 pm »
Thanks. The select-proc command fails.

Does select-proc work with the latest fixes for next build?

Glad to hear it is fixed in next beta. Looking forward to getting it.

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #8 on: September 09, 2016, 07:29:02 pm »
I am having this same issue on a different file, test3.c, in beta5. I have uploaded this file as part of a .zip to support.slickedit.com.

Go to line 4084, and search for "user_id" with "Look in:" as "<Current Procedure>", and choose "List all occurrences".

You will see that only the "user_id" after line 4084 are shown. Additionally, user_id after the end of the function (line 7298) are shown in the results, and they should not be there.

Running "select-proc" on line 4084 fails.

However, SE does seem to know the right function because in the toolbar and defs window, when I am on line 3689, it shows uls_crc_handling() - see screenshot 1 in the zip file

If I put the cursor on line 3688 (opening brace of uls_crc_handling()) and press Ctrl+[, it correctly finds the closing brace of the function on line 7298.

Finally, if cursor is on line 7319, toolbar and defs window correctly shows that I am inside uls_pusch_dtx_processing, see screenshot 2 in the .zip file.

As with previous posts, you need following preprocessor settings:

 I have the following 3 set as "undef":

HOST
LTE_FRAME_TYPE_2
METRO_2x2

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4481
  • Hero Points: 344
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #9 on: September 12, 2016, 03:03:21 pm »
The current implementation of select-proc requires that the outer function braces match (Press Ctrl+] on start or end brace and it will fail). This is why your this function in test3.c doesn't work. We will see if we can do something about this limitation. Assuming we can fix this, it's hot fixable.

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #10 on: September 12, 2016, 03:07:07 pm »
When I use Ctrl+], it passes and correctly finds the closing brace. Are you saying this is failing for you? It works for me.

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #11 on: September 12, 2016, 03:08:44 pm »
When I go to line 3688 of test3.c, and press Ctrl+[, it correctly takes me to line 7298 where the closing brace is.

And from the screenshots I included, you can see that defs window and toolbar also are able to know when we are inside/outside the function.

Did you remember to set the preprocessor settings that I put into my previous post?

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4481
  • Hero Points: 344
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #12 on: September 12, 2016, 03:24:11 pm »
Definitely not working for me. If I try Ctrl+[ at the start, it says "Match not found". If I try Ctrl+] at the end, it goes to the wrong line (line 4047).

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #13 on: September 12, 2016, 03:26:23 pm »
Did you configure your preprocessor?

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Find in "Current Procedure" does not wrap (C language)
« Reply #14 on: September 12, 2016, 03:29:23 pm »
Do you have the following 3 set as "undef":

HOST
LTE_FRAME_TYPE_2
METRO_2x2