Don't show context menu for paths

15 views
Skip to first unread message

Daniel Sahlberg

unread,
Sep 15, 2024, 10:13:52 AM9/15/24
to TortoiseSVN-dev
Hi,

Is there any documentation how the setting "Don't show context menu for paths" should work?

I realised that to ignore my working copy c:\temp\wc\ completely, I had to set either
  • "c:\temp\wc*"
  • Both "c:\temp\wc" and "c:\temp\wc\*"
The first one also ignored c:\temp\wc2\.
The second being quite clumsy.

This is handled in ShellCache::IsContextPathAllowed(LPCWSTR path). If right-clicking the folder itself, path will be c:\temp\wc

I'm considering to check the list of ignored paths for a trailing \* as follows (adding the ternary operator to check for \\).

        if (!I->empty() && I->at(I->size() - 1) == '*')
        {
            std::wstring str = I->substr(0, I->size() - (I->at(I->size() - 2) == '\\' ? 2 : 1));

Then c:\temp\wc\* would work, but it might crash on a single * (didn't check yet).

Or to check separately for trailing \:

        else if (!I->empty() && I->at(I->size() - 1) == '\')
        {
            std::wstring str = I->substr(0, I->size() - 1);
            if (_wcsnicmp(str.c_str(), path, str.size()) == 0)
                return FALSE;
        }

Basically treating \ as a wildcard character - then you could add c:\temp\wc\ as "ignore the wc folder and everything below".

What do you think? Any risk of regressions?

While I was at it, I'd suggest to remove the check for !I->empty() in the if statement. There is already a separate statement:

        if (I->empty())
            continue;

just above. So we KNOW that I->empty() is false. Do I miss something here? (For comparison, TortoiseGit don't have that !I->empty() check).

Kind regards,
Daniel

Stefan

unread,
Sep 15, 2024, 1:24:22 PM9/15/24
to TortoiseSVN-dev
On Sunday, September 15, 2024 at 4:13:52 PM UTC+2 daniel.l...@gmail.com wrote:
This is handled in ShellCache::IsContextPathAllowed(LPCWSTR path). If right-clicking the folder itself, path will be c:\temp\wc

I'm considering to check the list of ignored paths for a trailing \* as follows (adding the ternary operator to check for \\).

        if (!I->empty() && I->at(I->size() - 1) == '*')
        {
            std::wstring str = I->substr(0, I->size() - (I->at(I->size() - 2) == '\\' ? 2 : 1));

but first check that the string has at least two chars, otherwise a -2 would make it crash.
 
Then c:\temp\wc\* would work, but it might crash on a single * (didn't check yet).

Or to check separately for trailing \:

        else if (!I->empty() && I->at(I->size() - 1) == '\')
        {
            std::wstring str = I->substr(0, I->size() - 1);
            if (_wcsnicmp(str.c_str(), path, str.size()) == 0)
                return FALSE;
        }


that would work too. I don't really have a preference here.
 
Basically treating \ as a wildcard character - then you could add c:\temp\wc\ as "ignore the wc folder and everything below".

What do you think? Any risk of regressions?

No, no risk of regressions.
 

While I was at it, I'd suggest to remove the check for !I->empty() in the if statement. There is already a separate statement:

        if (I->empty())
            continue;

just above. So we KNOW that I->empty() is false. Do I miss something here? (For comparison, TortoiseGit don't have that !I->empty() check).


yes, you can remove that.

Stefan

Daniel Sahlberg

unread,
Sep 18, 2024, 3:45:10 AM9/18/24
to TortoiseSVN-dev
Thanks.

I've committed some code as r29713. I've tested with the following layout:

c:\temp\wc
c:\temp\wc2

"Don't show" set as c:\temp\wc

The context menu is shown when right-clicking anywhere in c:\temp, except when right-clicking on c:\temp\wc. The context menu is shown within c:\temp\wc2\. The context menu is not shown within c:\temp\wc\. I think that is reasonable.

Kind regards,
Daniel

 

Stefan

unread,
Sep 18, 2024, 3:09:02 PM9/18/24
to TortoiseSVN-dev
On Wednesday, September 18, 2024 at 9:45:10 AM UTC+2 daniel.l...@gmail.com wrote:

I've committed some code as r29713. I've tested with the following layout:

c:\temp\wc
c:\temp\wc2

"Don't show" set as c:\temp\wc

The context menu is shown when right-clicking anywhere in c:\temp, except when right-clicking on c:\temp\wc. The context menu is shown within c:\temp\wc2\. The context menu is not shown within c:\temp\wc\. I think that is reasonable.

 looks very good, thanks!

Stefan
Reply all
Reply to author
Forward
0 new messages