VScode 中的 JavaScript 颜色突出显示错误 [英] JavaScript color highlighting error in VScode

查看:48
本文介绍了VScode 中的 JavaScript 颜色突出显示错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我全新安装了 VScode 编辑器 (v.1.14.2).没有安装任何扩展.我在非常简单的文件中遇到了 javaScript 突出显示的问题.

I have fresh install of VScode editor (v.1.14.2). Doesn't have any installed extensions. I have problem with javaScript highlighting in very simple file.

Sublime Text 3 中的相同代码:

The same code in Sublime Text 3:

默认VScode主题(Dark+),没有这个bug,所有的函数名和方法的颜色都一样.但是许多其他主题(例如monokai 和 Abyss)都有这个错误/功能.

Default VScode theme (Dark+), doesn't have this bug, and all function names and methods have the same colors. But many another themes (monokai and Abyss for example) have this bug/feature.

我希望函数名和方法的颜色相同(第 10、11、13、16 行).理想情况下,所有行都像 ST3 - 蓝色(第 13 行 - 绿色).但是,如果是绿色也没关系.

I want to have for function names and methods the same color (line 10, 11, 13, 16). Ideally, all lines like in ST3 - blue (line 13 - green). But, it's ok if it would be a green.

我阅读了范围命名链接,尝试比较不同的主题.安装所有基于 monokai 的主题,但所有主题都有这个错误.我试图创建一个新的,但我没有做我需要的.

I read scope naming link, try to compare different themes. Install all monokai-based themes, but all of theme, has this bug. I tried to create new one, but I didn't do what I need.

那么,有可能解决这个问题吗?

So, does it possible to fix this?

推荐答案

您可以使用 vscode 命令 Developer: Inspect TM Scopes 进行范围检查.这个颜色改变是因为 vscode 认为 click(), addEventListener()... 是特殊的 DOM 相关属性,应该高亮显示.

You can use vscode command Developer: Inspect TM Scopes for scope inspection. This color changes because vscode thinks click(), addEventListener()... is special DOM-related properties and should be highlighted.

解决方法是修改

Microsoft VS Code\resources\app\extensions\theme-monokai\themes.

在这个数组中 "tokenColors": [] 添加:

In this array "tokenColors": [] add:

{
    "name": "DOM & invocation color fix",
        "scope": "meta.function-call.js entity.name.function, meta.function-call.js support.function.dom.js",
            "settings": {
        "foreground": "#66D9EF"
    }
}

这将使函数调用 &DOM-methods sublime-like.

This will make function calls & DOM-methods sublime-like.

附言如果主题更新,它很可能会覆盖此文件.

P.S. If theme updates it will most likely overwrite this file.

从某些版本可以从 settings.json Ctrl+,

From some version it is possible to modify theme from settings.json Ctrl+,

"editor.tokenColorCustomizations": {
    "textMateRules": [
        {
            "scope": ["meta.function-call.js entity.name.function", 
                "meta.function-call.js support.function.dom.js"],
            "settings": {
                "foreground": "#66D9EF"
            }
        }
    ]
}

这篇关于VScode 中的 JavaScript 颜色突出显示错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆