【问题标题】:How to disable only error syntax highlighting in Sublime Text 3?如何在 Sublime Text 3 中仅禁用错误语法突出显示?
【发布时间】:2016-04-01 22:26:47
【问题描述】:

我已经为 Sublime Text 3 安装了 TypeScript 包。我希望它仍然为代码语法着色,但不是红色下划线并抱怨错误。我似乎无法在偏好中找到任何可以为我做这件事的东西。我该怎么做?

【问题讨论】:

    标签: typescript sublimetext3 sublimetext sublime-text-plugin


    【解决方案1】:

    临时解决方案:在.../Packges/TypeScript/typescript/commands/error_info.py 中注释第 26 - 29 行(包括)并重新启动 sublime。如果您在构建错误时遇到此问题,您可能还希望在 sublime 设置中禁用内联错误"show_errors_inline": false,

    ...
    if len(error_text) > 0:
      # if PHANTOM_SUPPORT:
      #       template = '<body><style>div.error {{ background-color: brown; padding: 5px; color: white }}</style><div class="error">{0}</div></body>'
      #       display_text = template.format(error_text)
      #       self.view.add_phantom("typescript_error", self.view.sel()[0], display_text, sublime.LAYOUT_BLOCK)
      self.view.set_status("typescript_error", error_text)
    

    https://github.com/Microsoft/TypeScript-Sublime-Plugin/issues/556#issuecomment-260439591

    注意:这会禁用大红色块,但会留下红色下划线。如果您也不想要这些,请评论整个文件。

    【讨论】:

      【解决方案2】:

      这是一个 hack,但它会做你想做的事:

      • 找到 TypeScript 包的文件夹。您可以在 Sublime 中执行此操作:Preferences > Browse Packages。在我的系统上,这个文件夹位于/home/jack/.config/sublime-text-3/Packages/TypeScript
      • TypeScript 文件夹中打开typescript 文件夹,然后打开listeners 文件夹。

      • 将文件error_list.py重命名为error_list_old.py

      • 重启 Sublime

      这将删除红色下划线和插件对错误的抱怨,但也会删除整个错误列表功能(因此插件将不再告诉你它认为你的 TypeScript 代码有什么问题)。

      如果您只想删除红色下划线(但保留其余部分),它可能位于该文件中的某个位置。

      【讨论】:

      • 这行得通——问题是我不能再将粘贴复制到 TypeScript 文件中了。我猜这会消灭所有听众,并且复制粘贴功能以某种方式包含在其中。
      • 耻辱。您仍然可以使用右键单击 > 粘贴来粘贴,对吧?
      猜你喜欢
      • 2015-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-02-22
      • 1970-01-01
      相关资源
      最近更新 更多