ryu1kn / vscode-text-marker

Visual Studio Code Extension. Select text in your code and mark all matches. The marking colour is configurable
https://marketplace.visualstudio.com/items?itemName=ryu1kn.text-marker
MIT License
87 stars 17 forks source link

Apply highlights only to the current file #11

Open Otiel opened 6 years ago

Otiel commented 6 years ago

Could we have an option to apply highlights to the current file only?

ryu1kn commented 6 years ago

Hi @Otiel , thanks for the suggestion. I'm curious to know why you want this option: i.e. when do you want to highlight patterns only in the current file?

Otiel commented 6 years ago

This is how I usually use TextMarker:

  1. Open a file (log...) inside vscode without opening a workspace or a folder,
  2. Apply highlights to the terms I want to keep in my sight.

But at the same time, I have several other tabs opened in vscode, that have nothing to do with my log file. Thus I don't want to see highlights on those tabs.

Hope that makes sense.

ryu1kn commented 6 years ago

I see... but this could be a bit tricky. We need to make whether highlight rules are applied to the current tabs super noticeable; otherwise users may get confused if there are actually no matches or just not enabled.

Maybe for now, you can get around with opening up a separate editor window for the log? It should work until we do #10 ...

Otiel commented 6 years ago

Yes indeed. Apart from adding an indicator on the status bar, I'm not sure how you could display the difference.

colelawrence commented 6 years ago

I was imagining that you could scope the textmarker highlights to specific file types. This would be easiest for me, because I could simply add my highlight twice if necessary.

ryu1kn commented 6 years ago

@colelawrence That’s an interesting idea 💡 We can introduce a config that allows you to limit the scope of highlight, like textmarker.limitHighlightToSameFiletype

colelawrence commented 6 years ago

@ryu1kn, yes. Then you might have a command: TextMarker: Toggle Filetype Limitation, but in the config:

{
  "textmarker.savedHighlights": [
    {
      "pattern": {
        "type": "string",
        "expression": "Printf",
        "ignoreCase": false,
        "wholeMatch": false,
        "filetypes": [
          "go",
          "typescript",
          "typescriptreact"
        ]
      }
    }
  ]
}