1

How can I add custom colors to only output channel created by my extension? Currently I have this package.json

{
  "name": "mytestextension-output-colors",
  "displayName": "My test extension - output colors",
  "version": "0.0.1",
  "publisher": "nobody",
  "engines": {
    "vscode": "^1.72.0"
  },
  "main": "./extension.js",
  "activationEvents": [
    "onStartupFinished"
  ],
  "contributes": {
    "languages": [
      {
        "id": "mytestextension-output",
        "aliases": [],
        "mimetypes": [
          "text/x-code-output"
        ]
      }
    ],
    "grammars": [
      {
        "language": "mytestextension-output",
        "scopeName": "text.mytestextension-output",
        "path": "./mytestextension-output.tmLanguage.json"
      }
    ],
    "configuration": {
      "type": "object",
      "title": "My Test Extension - output colors"
    },
    "configurationDefaults": {
      "editor.tokenColorCustomizations": {
        "textMateRules": [
          {
            "scope": "mytestextension-output-red",
            "settings": {
              "foreground": "#f00080"
            }
          }
        ]
      }
    }
  }
}

extension.js

const window = require("vscode").window;

function activate() {
  const out = window.createOutputChannel("myextension test output", "mytestextension-output");
  out.appendLine(`red output`);

}

function deactivate() {}

module.exports = {
    activate,
    deactivate
};

mytestextension-output.tmLanguage.json

{
  "$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
  "name": "mytestextension-output",
  "scopeName": "text.mytestextension-output",
  "patterns": [ {
      "match": ".*",
      "name": "mytestextension-output-red"
    }
  ]
}

Even though the grammar is set for mytestextension-output id/scope, it applied to and changes color to red in all output channels (git, tasks, extensions, etc)

What am I missing here?

Gist example

vanowm
  • 9,466
  • 2
  • 21
  • 37

0 Answers0