Giter VIP home page Giter VIP logo

language-batchfile's People

Contributors

cpterion avatar mataha avatar mmims avatar msftrncs avatar pchaigno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

language-batchfile's Issues

Syntax highlighting goes haywire with multiple inline assignments, one arithmetic

GitHub (Linguist)

It appears that only arithmetic assignments combined with assignments in quotes cause this (possibly due to mismatched quote detection?):

:: This will work...
set var=val & set var=val
:: This as well...
set "var=val" & set var=val
:: This... will, I guess?
set /a var=val & set var=val
:: This won't.
set /a "var=val" & set var=val
:: Aaaand everything's screwed.
set sadness=true
title it's over
echo weep woop
exit /b -42

A real-world example can be seen here.

Highlight bugs regarding quotes (GitHub's highlighter)

I discovered two bugs on GitHub's batch file highlighting and from this I am recommended to report it here:

Test code

SETLOCAL EnableDelayedExpansion
REM Stripping quotes from a variable
SET foo=some^"quoted^"text
SET bar=!foo:^"=!
REM ^"

actual result and expected result

This look like two problems that happen simultaneously in the code above:

  1. Escaped quotes are not identified and highlighter still thinks the quoting is still in effect.
  2. Highlighter thinks the quote effects cross newlines, but in fact it's not. (Batch is unlike Unix shell, the latter have quotes span newlines)

Because of the bugs, I worked-around by batch script.

Variable string substitution not highlighted as expected.

image

When using variable string substitution, the highlight is including till the next variable's end "%".
This might get fixed by setting your matcher:

      {
        'match': '%[\\w -]+?(:~\\-?\\d+(,\\-?\\d+)?|:.+=.+)?%'
        'name': 'variable.other.environment.batchfile'
      }

to this:

%[\\w -]+?(:~\\-?\\d+(,\\-?\\d+)?|:.+?=.*?)?%

Thanks for fixing the parameter highlight. Sorry for bothering you again.

Thanks
Subhajit

A batch parameter doesn't tend to be applied to themes correctly, incompletely scoped.

A batch parameter (percent (%) number) reference doesn't seem to be scoped correctly, and as such it doesn't get colored correctly in editors, such as VS Code (1.25.1 on Windows 10 1803)

Currently, it only ends up scoped in "punctuation.definition.variable.batchfile", unlike the normal variable '%', which gets included in both scopes, "punctuation.definition.variable.begin.batchfile"
"variable.other.readwrite.batchfile"

image
image

I think the single % that is used to determine the scope "variable.parameter.batchfile" should be included in that scope, and then themes would color it like they do the rest of the parameter.

I was able to work around the issue of the % in front of a 'variable.parameter' not being scoped with the 'variable.parameter', by adding this to settings:

    "editor.tokenColorCustomizations": {
        "[Default Dark+]": {
            "textMateRules": [
                {
                    "scope": "punctuation.definition.variable",
                    "settings": {
                        "foreground": "#9cdcfe"
                    }
                }
            ]
        }
    }

image

[bat] The command `set "flag="` breaks syntax highlighting

From @DmitrySokolov on February 1, 2018 13:49

  • VSCode Version: Code 1.19.3 (7c4205b5c6e52a53b81c69d2b2dc8a627abaa0ba, 2018-01-25T10:36:34.867Z)
  • OS Version: Windows_NT x64 10.0.16299
  • Extensions:
Extension Author (truncated) Version
hg mrc 1.2.3
cpptools ms- 0.14.6
cmake twx 0.0.17

(2 theme extensions excluded)


Steps to Reproduce:

  1. Create test.cmd
@echo off
setlocal
set "flag="
endlocal

exit /b 0

EXPECTED
endlocal and the rest of command are highlighted

ACTUAL
endlocal and the rest of command have the default font color

Reproduces without extensions: Yes

Copied from original issue: microsoft/vscode#42733

Syntax highlight broken for Batch file

From @wlai2768 on January 7, 2018 1:40

Steps to Reproduce:

  1. Open a new file
  2. Change file type to Batch file
  3. Paste below two lines. The first "for" line color rendering is broken.
for %%i in ( %* ) do if "%%i"=="--watch" goto :do_%1_%2_watch
for %%i in ( 
    %* 
) do if "%%i"=="--watch" goto :do_%1_%2_watch

Copied from original issue: microsoft/vscode#41235

Parameter Highlight is not as expected

image

Plugin is considering "%2 %" as a variable.
Hence, it is considering "3 " as text.
Plugin is considering "%4 %" as a variable.
Hence, it is considering "5 " as text.
...

Thanks
Subhajit

Ignore words in comments

Like: ## Get runner for windows or ## Install and start services

The keywords start and for not are commands, its just comments and should be ignore.

Batch Script syntax highlighting issues

From @Kroc on April 6, 2018 8:35

Issue Type: Bug

There are a handful of highlighting issues with Windows Batch files:

  • ECHO: is not recognised, when ECHO. is; ECHO: is faster as it does not do a file lookup! -- see: https://ss64.com/nt/echo.html

  • The OFF in ECHO OFF is not highlighted

  • The following code gets highlighting confused (the "$... seems to throw it off)

    vscode_batch_syntax

  • No space between GOTO and the label name does not highlight correctly; i.e. GOTO:EOF

  • CLS keyword is not highlighted

  • EQU / NOT and other comparison operators are not highlighted

  • IN & DO are not highlighted

  • command concatenator &, and the pipe operators >, | are not highlighted nor pipe numbers for redirection, e.g. >NUL 2>&1 (a common way to suppress all output)

  • error-suppressor @ is not highlighted in any way; this needs to be highlighted when used with a command, but not within 'strings' (which may or may not be quoted, according to command used)

  • ENABLEEXTENSIONS / DISABLEDELAYEDEXPANSION etc. not highlighted along with SETLOCAL

  • Syntax break-down here: (looks like the quoted paren-escape failed to be noticed)

    vscode_batch_syntax2


Aside: What would be the best way to broach a discussion on using a PEG-based parser, rather than the regex-infused TextMate system for VSCode? Windows Batch files happen to be one of the best examples of extremely complex mode-like behaviour that would be easily and elegantly handled by a real state machine based approach using PEG/EBNF grammars. Grammar based parsing would also be readily shareable between language servers and other external software.


VS Code version: Code 1.22.1 (950b8b0d37a9b7061b6f0d291837ccc4015f5ecd, 2018-04-06T02:26:57.615Z)
OS version: Windows_NT x64 10.0.16299

Extensions: none

Copied from original issue: microsoft/vscode#47297

Parsing Comment Blocks

Text typed as comments in a comment block is being parsed and colored as if it's code. Not breaking, but for some reason it's annoying me to distraction.

/*
[text here is being parsed/lexed and colored]
*/

Recognize "*" prefix of pattern substitution (%v:*s=r%)

This is a feature request.

SET var=banana
ECHO %var:*NA=An% & REM Output: Anna
ECHO %var:NA=s% & REM Output: bass
SET var=f*cker
ECHO %var:**CK=bust% & REM Output: buster
ECHO %var:**C=ba% & REM Output: baker
ECHO %var:*F*C=coo% & REM Output: cooker

The first asterisk * in the pattern should be recognized as special.
For the example screenshot below, the first asterisk right after the colon is better colored red just like the colon is:
screenshot

Package.loadSettings is deprecated.

Store package settings files in the settings/ directory instead of scoped-properties/

Package.loadSettings (C:\Users\k_sevrjugin\AppData\Local\atom\app-0.189.0\resources\app\src\package.js:565:9)
<unknown> (C:\Users\k_sevrjugin\AppData\Local\atom\app-0.189.0\resources\app\src\package.js:187:43)

"Caret-quote ^" should terminate quoted text

Test code:

SET "caret=^" & ECHO.
ECHO An unquoted caret "^" is set in the variable & ECHO named "caret".

Actual result (opened in Atom text editor; the wrong result)
screenshot

The caret quote ^" should still terminate the quoted text. Carets can never escape quotes from within quotes.

Label colour

So the label is just white and not italic, I don't know if this a bug or not but I think it looked much better when it was italic and coloured.

How to install?

Hello, I'm new to Atom. I already learned how to install a package with apm in the command prompt. But I can't figure out how to install this BATCH auto complete support. I'd appreciate the help.

windows bat file syntax highlighting problem

Type: Bug

windows batch:

if not %errorlevel%==0 echo error!!! & echo; & exit /b
if not %errorlevel%==0 echo error!!! && echo; && exit /b
if not %errorlevel%==0 echo error!!! || echo; || exit /b

image

the second "echo" and "exit" command not highlighting

VS Code version: Code 1.74.2 (e8a3071ea4344d9d48ef8a4df2c097372b0c5161, 2022-12-20T10:29:14.590Z)
OS version: Windows_NT x64 10.0.22621
Modes:
Sandboxed: No

System Info
Item Value
CPUs AMD Ryzen 5 5600X 6-Core Processor (12 x 3700)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off
Load (avg) undefined
Memory (System) 15.93GB (2.93GB free)
Process Argv K:\EasyU\driver\_common_printer_add.bat --crash-reporter-id bbaba037-8e76-4429-9304-78de16cb0895
Screen Reader no
VM 0%
Extensions (34)
Extension Author (truncated) Version
ZwLisp Zws 1.0.8
maxscript And 0.0.2
bat-snippets bat 0.2.0
auto-align bla 0.0.13
prettier-toml bod 0.1.0
vscode-better-align cho 1.3.1
xml Dot 2.5.1
vscode-glsllint dto 1.8.0
shell-format fox 7.2.2
reg ion 1.1.0
columnpaste joh 0.0.7
vscode-smart-column-indenter lmc 0.0.13
auto-build mar 2.1.45
clang-format mjo 1.10.0
vscode-language-pack-zh-hans MS- 1.74.12140931
csharp ms- 1.25.2
isort ms- 2022.8.0
python ms- 2022.20.1
vscode-pylance ms- 2022.12.20
jupyter ms- 2022.11.1003412109
jupyter-keymap ms- 1.0.0
jupyter-renderers ms- 1.0.12
vscode-jupyter-cell-tags ms- 0.1.6
vscode-jupyter-slideshow ms- 0.1.5
cpptools ms- 1.13.8
powershell ms- 2022.12.1
platformio-ide pla 2.5.5
vscode-xml red 0.23.0
vscode-yaml red 1.10.1
vscode-vba ser 0.8.0
shader sle 1.1.5
sq sq 0.0.1
even-better-toml tam 0.19.0
clang-format xav 1.9.0
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vstes627:30244334
vslsvsres303:30308271
pythonvspyl392:30443607
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
cmake_vspar411:30581797
vsaa593:30376534
pythonvs932:30410667
cppdebug:30492333
vsclangdc:30486549
c4g48928:30535728
dsvsc012cf:30540253
azure-dev_surveyone:30548225
pyindex848:30577860
nodejswelcome1cf:30587006
2e4cg342:30602488
3d0df643:30613357
89544117:30613380
fim-prod:30623723

From @kokutoukiritsugu in microsoft/vscode#170593

Echos and quotation marks

When echoing something that contains a simple quote ('), the following text is interpreted as a string until it finds another matching simple quote (e.g. echo It's OK.).

This breaks all further syntax highlighting.

Could it be possible to ignore simple quote that are part of an echo? Would there be a downside to it?

Syntax Highlighting for Batch scripts doesn't handle percent escapes

If a batch script references a file with a percent (%) sign in it, the percent needs to be doubled to escape it. VS code seems not to apply correct syntax highlighting to this.
example


Steps to Reproduce:

  1. Save a batch file containing (for example) text copy "50% done.txt" %K%
  2. Make sure Language Mode is Batch
  3. See highlighting is not right

Copied from original issue: microsoft/vscode#42472

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.