Skip to content

Fix Python Function List not showing functions#9844

Closed
littlej541 wants to merge 1 commit intonotepad-plus-plus:masterfrom
littlej541:python-function-list-fix
Closed

Fix Python Function List not showing functions#9844
littlej541 wants to merge 1 commit intonotepad-plus-plus:masterfrom
littlej541:python-function-list-fix

Conversation

@littlej541
Copy link
Contributor

Functions defined at the top of the file or below a class with nothing in between would not show in the Function List.

This changes the function regex to fix this. A small unit test that the old regex won't pass but the new will included.

Old regex:
oldregex

New regex:
newregex

Functions defined at the top of the file or below a class with nothing in between would not show in the Function List.

This changes the function regex to fix this. A small unit test that the old regex won't pass but the new will included.
@donho donho self-assigned this May 11, 2021
@donho
Copy link
Member

donho commented May 11, 2021

@littlej541
I remove all linebreaks between VisibleClass1 and invisible_function2 and tested with current version (v7.9.5), but invisible_function2 is still invisible. Any idea about it?

@donho donho requested a review from sasumner May 11, 2021 11:48
@sasumner
Copy link
Contributor

@littlej541 Providing the text of the file as well as the screenshots would have been helpful.

@donho
Copy link
Member

donho commented May 11, 2021

@sasumner
The file is UnitTest file added in this PR:
https://github.com/notepad-plus-plus/notepad-plus-plus/pull/9844/files#diff-2da07893dd944103c051ba9b308829cbaf1f21de44fbacf64e4fe11b6f8a29eb

@littlej541
Copy link
Contributor Author

littlej541 commented May 11, 2021

@littlej541
I remove all linebreaks between VisibleClass1 and invisible_function2 and tested with current version (v7.9.5), but invisible_function2 is still invisible. Any idea about it?

With the old regex, it searches for whitespace before the def. However, the class regex eats up all the whitespace right up to the def. This can be seen in when running the VS debugger and placing a breakpoint here or so and observing the targetStart and targetEnd values.

The invisible functions will not show unless something is in between the class and function to allow some white space (a line break in this case) to be preserved before the def. I simply changed the whitespace requirement to a line start in the pull request so that the class can gobble up the whitespace all it wants and the function will still show.

If it is not showing for you and you are using the new regex, I cannot say what's going on. I don't want to sound presumptuous, but you have placed the altered python.xml from the pull request in the appropriate location either in the %appdata%\Roaming\Notepad++\functionList folder or in the functionList folder in the exe directory? And you don't have another overwriting it from the %appdata% location if you have it in the exe directory?

@ArkadiuszMichalski
Copy link
Contributor

@donho Works for me. Maybe you replaced the regex on the wrong line? It's best to replace the entire python.xml file and check.

image

@donho
Copy link
Member

donho commented May 11, 2021

@littlej541
Thank you for your explanation.
I put invisible_function2 on the same line of class by adding some white space. Now I can see it's recognized.

@ArkadiuszMichalski
I didn't apply the fix, just with the UnitTest to see if remove line breaks can make it works. (it work only without line breaks according the description of provided script)

</classRange>
<function
mainExpr="\sdef\x20\K.+?(?=:)"
mainExpr="^def\x20\K.+?(?=:)"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@littlej541 Why not the same change on line 25?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line 25 is for function definitions inside classes. These need whitespace before them and so they will never be at the start of a line.

@donho donho added the accepted label May 11, 2021
@donho donho closed this in 84402e7 May 11, 2021
@littlej541 littlej541 deleted the python-function-list-fix branch May 12, 2021 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants