Closed JacquesSyn closed 1 year ago
@jamesonknutson please🙏🙏
@JDurSyn
This is because the format for a RegExp rule does not match the one you provided. An example of a valid RegExp rule looks like this:
{ "type": "regexp", "value": { "source": "regexp-source", "flags": "im" } }
Try using this configuration, instead, and let me know if it fixes your issue:
"disable-copilot-comment-completions.textMateRules": [
{
"type": "regexp",
"value": { "source": "^meta\\.import\\.ts$" }
},
{
"type": "regexp",
"value": { "source": "^meta\\.import\\.py$" }
}
]
Will something like this do the trick ?
"disable-copilot-comment-completions.textMateRules": [
{
"type": "string",
"mode": "startsWith",
"value": "import "
},
{
"type": "string",
"mode": "startsWith",
"value": "from "
},
]
Basically disable completion if I start a string with "import " (python / typescript) or "from" (python)
Will something like this do the trick ?
"disable-copilot-comment-completions.textMateRules": [ { "type": "string", "mode": "startsWith", "value": "import " }, { "type": "string", "mode": "startsWith", "value": "from " }, ]
Basically disable completion if I start a string with "import " (python / typescript) or "from" (python)
You are confusing the role of textMateRules with contentRules. The textMateRules setting defines rules that are matched against the text mate scopes of the current cursor position. Text mate scopes are like the ones your original post referred to— “meta.import.ts”, etc.
The contentRules setting defines rules that apply against the plain text content of the line the cursor is at.
So, if you want to define rules that apply based on the actual text content of the source code near the cursor position, you have to use contentRules. Content Rules allow you to use more nuanced and specific conditions that are more finely tuned to your code base, at the cost of likely missing more generic cases that you’d otherwise want to be able to match.
And vice versa, text mate rules are meant to serve as more generic, broad exclusions. Being that the text mate rules are evaluated against the standardized token / scope information about the cursor position, you don’t get the same fine-grained control over what the rule applies to like you would with content rules.
All that being said, I think my original suggestion remains the best option for your use case, but if you wanted to use content rules (as implied by your reply) instead of text mate rules, you would want to use this configuration:
"disable-copilot-comment-completions.contentRules": [
{
"type": "string",
"mode": "startsWith",
"value": "import "
},
{
"type": "string",
"mode": "startsWith",
"value": "from "
},
]
you could also play around with the option for content rules that lets you expand the lines that are evaluated against the rules condition to make this better suited for multi line imports, but I think you’d be shooting your self in the foot by not using text mate rules in this case.
Have you tried my original suggestion yet? If so, and you didn’t find it satisfactory, why is that? Maybe I can help you better that way
Will try the 1st suggestion and provide feedback đź‘Ť
Will try the 1st suggestion and provide feedback đź‘Ť
Have you had a chance to test and see whether my suggestion solves the issue for you? @JDurSyn
Yes it seems it worked well ! Thank you so much !!
(Closing this issue)
I tried adding to settings.json :
But it did not work
Edit : I think it is a huge use-case for your extension, you could add them to your examples