Author Topic: Python - wrong argument highlighted in 22.0.1  (Read 620 times)

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Python - wrong argument highlighted in 22.0.1
« on: January 05, 2018, 04:46:30 am »
After typing the open parenthesis in a function call in python with 2 arguments, the second argument is highlighted when the first one should be highlighted instead.

See attached screenshot - wrong_arg.png.

This only happens when an __init__.py file is in the same directory.

To reproduce:
1) Use a clean config
2) Extract attached pyargs.tar.gz file so that __init__.py and test.py are in the same directory.
3) Open test.py
4) On line 10, after 'func1' type an open parenthesis. Notice that arg2 gets highlighted (see attached screenshot)

On a related note, sometimes when typing the open paren after func1(), the arguments are not just highlighted, but placed into the text in the editor (for example after typing open paren, 'arg1' would automatically be typed in by SE), but sometimes not. What controls this?

I'm using 22.0.1 on Linux x64 on CentOS 7.

Thanks,
Rob
« Last Edit: January 05, 2018, 04:49:03 am by rowbearto »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4484
  • Hero Points: 344
Re: Python - wrong argument highlighted in 22.0.1
« Reply #1 on: January 05, 2018, 02:24:13 pm »
Reproduced. Looking into this.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2501
  • Hero Points: 364
Re: Python - wrong argument highlighted in 22.0.1
« Reply #2 on: January 05, 2018, 04:03:33 pm »
This will be fixed in the next hot fix.

The other option you are asking about is Document > Python Options... > Context Tagging(R) > Auto-insert matching parameter.  It inserts the matching parameter if there is a local variable whose name matches the name of the parameter in the formal argument list.

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Python - wrong argument highlighted in 22.0.1
« Reply #3 on: January 05, 2018, 04:12:42 pm »
Thanks for the quick work Dennis and Clark!

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Python - wrong argument highlighted in 22.0.1
« Reply #4 on: January 05, 2018, 04:15:45 pm »
Dennis:

Using the test project I sent you, if I have the "Auto-insert matching parameter" enabled, then it adds arg2 into the argument list even though it is not defined as a local variable.

I also tried some cases in other python source where I enabled this option, created a local var with this name and it does not get inserted.

If you can't find simple test cases that reproduce this, I can spend some effort trying to create some.

Thanks,
Rob

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2501
  • Hero Points: 364
Re: Python - wrong argument highlighted in 22.0.1
« Reply #5 on: January 05, 2018, 05:47:46 pm »
I was not able to reproduce this with your sample.  Technically, the variable doesn't have to be a local, it could also be a global or class member found in the current scope, so maybe arg2 is being picked up from elsewhere.  You can verify that by hitting Ctrl+Dot on arg2 after it is inserted and see where it goes.

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Python - wrong argument highlighted in 22.0.1
« Reply #6 on: January 05, 2018, 06:12:50 pm »
When I ctrl+. with my sample, it is showing C/C++ files that are in a different project but in the same workspace, see attached screenshot.

Not sure if this is really valid to go to C/C++ symbol from python ???

Note that screenshot shows arg1 and not arg2 because I renamed the __init__.py file.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2501
  • Hero Points: 364
Re: Python - wrong argument highlighted in 22.0.1
« Reply #7 on: January 05, 2018, 08:40:51 pm »
Mixed language workspaces always present new problems.  I will put a fix for this into the next hot fix for 22.0.1.

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Python - wrong argument highlighted in 22.0.1
« Reply #8 on: January 05, 2018, 09:03:33 pm »
Thanks Dennis!

rowbearto

  • Senior Community Member
  • Posts: 1167
  • Hero Points: 73
Re: Python - wrong argument highlighted in 22.0.1
« Reply #9 on: January 05, 2018, 09:05:32 pm »
There may be some cases where I have python and C/C++ files in the same project as well, so you may want to consider that too.

Dennis

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 2501
  • Hero Points: 364
Re: Python - wrong argument highlighted in 22.0.1
« Reply #10 on: January 05, 2018, 09:42:25 pm »
I'm just kicking out any parameter name match that isn't from the same language mode.  Completely workspace/project independent that way.