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

Question: Maintaining highlighting after modifying block #56

Closed adam-zakaria closed 3 years ago

adam-zakaria commented 3 years ago

Hi Ryuichi - awesome plugin.

Say I highlight a block of code, is there a way to maintain the highlighting of the block if I add a line in the block. Ideally, the new line would be highlighted as well.

I've attached a video of the current behavior. This is my first time posting in GitHub issues, so apologies if this is poorly formatted or is the wrong place for this question. https://user-images.githubusercontent.com/5415505/105892166-74fcc380-5fdf-11eb-80a5-3a4dde52dd49.mov

ryu1kn commented 3 years ago

Hi @adam-zakaria , sorry for my super slow response. Your description is very clear and you even provided the very helpful video, thank you very much for that.

You can keep the highlight if you know the beginning & ending of the block by using a regex pattern. For example, you can wrap your block with # Begin highlight and # End highlight and you define a regex pattern # Begin highlight[\s\S]*# End highlight. In the saved form, it would look like this:

  "textmarker.savedHighlights": [
    {
      "pattern": {
        "type": "regex",
        "expression": "# Begin highlight[\\s\\S]*# End highlight",
        "ignoreCase": false,
        "wholeMatch": false
      }
    }
  ]

(Newline characters are not highlighted)

adam-zakaria commented 3 years ago

No problem @ryu1kn thanks for the response!!

ryu1kn commented 3 years ago

No worries. I'm closing this issue. Feel free to reopen it if you're not done yet with this issue 👌