Skip to content

Complicated regex in ValidatePattern breaks the grammar #132

Closed

Description

@vors
Function Get-Domain
{
    [CmdletBinding()]
    param(
        [ValidatePattern('^(?=^.{1,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)')]
        [Parameter(ValueFromPipeline = $true)] # this line should not be highlighted as a string
        [string]$domain
    )
}

Activity

  1. added this to the milestone on Jul 29, 2015
  2. vors commented on Feb 12, 2016

    @vors
    MemberAuthor

    Yes, this is the right place.
    Atom, VSCode and GitHub uses the same grammar.

    On Fri, Feb 12, 2016 at 6:07 AM, Bryan Childs [email protected]
    wrote:

    I have a fix for this, but I'm not sure where it should be sent - it seems
    various different editors use TextMate's language definition for
    Powershell, but I've never used TextMate (and can't, being as how I abhor
    Macs), so I can't text the fix there...

    —
    Reply to this email directly or view it on GitHub
    #132 (comment)
    .

  3. vors commented on Feb 12, 2016

    @vors
    MemberAuthor

    Oh, apparently another comment was removed

  4. daviwil commented on Feb 12, 2016

    @daviwil

    @godeater this is the right place :)

  5. godeater commented on Feb 12, 2016

    @godeater

    I removed the comment I put earlier as I found that the new grammar I had, although it didn't wreck the syntax highlighting through the rest of the buffer as the current one does, now only highlights on the first "variable=value" in a [Parameter( block.
    I'm trying to work out if it's worth submitting it still as the lesser of two evils, or keep plugging away to see if I can fix the regex properly.

  6. daviwil commented on Feb 12, 2016

    @daviwil

    Go ahead and fix it properly if you want to. Definitely doesn't make sense to pull it in yet if it breaks other highlighting.

  7. vors commented on Feb 12, 2016

    @vors
    MemberAuthor

    This regex became pretty complicated, good luck.
    You can share preview of your results with https://github-lightshow.herokuapp.com/

  8. godeater commented on Feb 12, 2016

    @godeater

    s/want to/can/ =/

    After I noticed that problem, I kept looking at it all afternoon without much success.

    Take a look at these and see which you think would be best to use.

    With current grammar:
    before

    With new grammar:
    after

  9. vors commented on Feb 12, 2016

    @vors
    MemberAuthor

    @godeater send a PR with a reference to this issue, we can take a look together.

    It always takes few hours to switch context to tmLanguage syntax, but I feel there were no releases for quite some time and GitHub's highlighting is out-of-date.

  10. godeater commented on Feb 12, 2016

    @godeater

    I've sent a pull request, but not sure if I've done it right or not.

  11. godeater commented on Apr 15, 2016

    @godeater

    I presume the decision was taken that this wasn't good enough?

  12. ScriptingDad commented on Dec 26, 2017

    @ScriptingDad

    Was this ever resolved? I seem to be having the same issue at present and it's making it difficult to switch to atom for powershell.

  13. vors commented on Dec 26, 2017

    @vors
    MemberAuthor

    @godeater hey sorry for a very long reply time: completely slipped out of my radar. It looks like you sent #145 , right?

    I think all maintainers just dropped ball here at the time, not that it was not good enough. Sorry for that.

  14. vors commented on Dec 26, 2017

    @vors
    MemberAuthor

    The plan was to move highlighting development to https://github.com/PowerShell/EditorSyntax but it stalled a little bit too.

  15. ScriptingDad commented on Dec 26, 2017

    @ScriptingDad

    Thanks for the update. Seems there are a few bugs related to syntax highlighting in there. I'll see how they're progressing.

  16. added theissue type on Dec 9, 2025
  17. michaelblyons commented on Dec 9, 2025

    @michaelblyons
    Collaborator

    How about this?

    Image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions