Giter Site home page Giter Site logo

Comments (8)

rkeithhill avatar rkeithhill commented on July 4, 2024

A command does not end with end of line if the last character is a backtick.

It might be easier to default to parameter colorization unless the -<token> matches one of the PowerShell operators. That list is long but manageable, I think. This approach has the unfortunate consequence of misrepresenting parameters that have the same name as a built-in operator. Not sure if that is an "acceptable loss" or not. :-)

from editorsyntax.

vors avatar vors commented on July 4, 2024

@rkeithhill That's pretty match how it's done right now. List of tokens already there (and around this line).
There is one difference: default for parameter names is "no-colorization" unless it matches -<token>. Then there is unfortunate collision.

@gravejester I really like idea of trying define commands regions. This generalization will help not only with parameters matching, but with other things as well. We can start with you described algorithm (+ back-tick) and see how it holds on the real world programs.

from editorsyntax.

gravejester avatar gravejester commented on July 4, 2024

@rkeithhill It might be simpler than you think (though I'd have to do some testing to be sure), because since we are defining start and end tokens, we can do matching across multiple lines (as opposed to when we are doing simple matching that only works per line).

So by saying that a command region starts at Verb-Noun and ends at either a pipeline or the end of the line, we don't have to worry about the back-tick at all, other than as an escape character. Well, that is not entirely true, as after a back-tick there would always have to be a end-of-line character, so we would have to let the matching regex ignore that if a back-tick is before it. But I think this is all do-able.

@vors So I guess the only way of being sure about this is to actually do some testing, so I will do that and give you some examples of the result, and we can decide if it's good enough or not :)

from editorsyntax.

gravejester avatar gravejester commented on July 4, 2024

I'll rephrase the command region as such to take into account the back-tick:

  • A command starts with either (Verb-Noun) or (alias) or (foreach-object | tee-object | where-object | sort-object)
  • A command ends with either (End of line/string, except if it follows a back-tic) or ('|' - the pipe character)

from editorsyntax.

vors avatar vors commented on July 4, 2024

There are complications, like you need to handle () correctly (in regards for |), because somebody can do

Get-Foo (1..20 | Out-String) -Param2 "param2"

from editorsyntax.

gravejester avatar gravejester commented on July 4, 2024

Hmm.. good point. That might actually be what breaks it, but I'll give it a shot anyway :)

We'll always have the suggestion from @rkeithhill as a backup plan.

from editorsyntax.

gravejester avatar gravejester commented on July 4, 2024

Ok, I have done some testing, and I think I have finally got it working. I just have to look for regressions.

It was a bit tricky to get the end-of-line-except-right-after-backtick to work properly. I used $ to end at end-of-line but this doesn't actually consume the end-of-line, which tripped me up for a while. Had to use \r and \n instead.

from editorsyntax.

gravejester avatar gravejester commented on July 4, 2024

Had to do some minor changes to get rid of some small regressions, but seems to work as intended now.

from editorsyntax.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.