Comments (8)
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.
@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.
@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.
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.
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.
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.
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.
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)
- its possible to implement empty coallesing operator HOT 3
- Comment Based Help Keywords and Their Parameters Not Highlighting Correctly HOT 2
- FTLOG Don't use light gray on a white background
- Powershell syntax highlighting disrupted by single quotes in HTML
- Function without arguments not colorized HOT 2
- foreach not scoped correctly after curly brace
- Asterisk is not recognized as valid function/cmdlet name character HOT 1
- Export-Member color coding issue
- Parameters are shown using variables-color HOT 7
- Version v2021.5.1 Semantic Textmate Scope is incorrect for negative numeric literals, when used as a parameter HOT 4
- No Syntax Highlighting for `enum` declarations HOT 2
- #Requires syntax highlighting bug HOT 2
- Syntax Highlighting doesn't recognize ? as part of a variable name
- Generic method type parameter support
- Syntax Highlighting: region incorrectly highlighted when defined as part of a hashtable
- Function name not recognized in definition when on different line
- word_wrap settings does not obey the global settings in sublime text HOT 1
- Attributes not attached to parameters aren't recognized as attributes but as a generic type
- Code thinks ArgumentCompleter attribute on parameter is the parameter's type
- Variables that are built-in constants are not highlighted, like `$Error` and `$PSVersionTable`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from editorsyntax.