Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension stopped working with v2.0.8? #69

Open
g-berthiaume opened this issue Apr 13, 2023 · 14 comments
Open

Extension stopped working with v2.0.8? #69

g-berthiaume opened this issue Apr 13, 2023 · 14 comments

Comments

@g-berthiaume
Copy link

The extension appears to have stopped working.

image

$  code --version
1.77.3
704ed70d4fd1c6bd6342c436f1ede30d1cff4710
x64

There's no log message in the extension console.
I'm not sure how to provide more information.

@g-berthiaume g-berthiaume changed the title Extension stopped working Extension stopped working with vscode v1.77.3 Apr 13, 2023
@jgclark
Copy link
Owner

jgclark commented Apr 13, 2023

More details please ... what extension version are you running; what's the definition of your highlight?

@g-berthiaume
Copy link
Author

g-berthiaume commented Apr 13, 2023

Hi @jgclark

Version:
TODO Highlight v2 (v2.0.8)

What I see:
(here TODO: should be highlighted)
image

What I tested:

  • Tested without any config (my settings.json without any todohighlight field) : does not work.
  • Tested with my normal config (has not been touched for years) : does not work.

All the test has been done in a C codebase

@RyanTheTechMan
Copy link

RyanTheTechMan commented Apr 13, 2023

I am running VS Code 1.78 and TODO Highlight 2.0.8. I am also experiencing a similar issue. However, if I open a different workspace, it works sometimes. If you would like me to test anything specific let me know.
Here is an example in my json file:

        {
            "text": "TODO:",
            "color": "yellow",
            "border": "1px solid yellow",
            "borderRadius": "2px",
            "backgroundColor": "rgba(0,0,0,.2)",
            "isWholeLine": true
        },
        {
            "text": "CHECK:",
            "color": "#34e8eb",
            "border": "1px solid #34e8eb",
            "borderRadius": "2px",
            "backgroundColor": "rgba(0,0,0,.2)",
            "isWholeLine": true
        },

@jgclark
Copy link
Owner

jgclark commented Apr 13, 2023

I am running VS Code 1.78 and TODO Highlight 2.0.8. I am also experiencing a similar issue. However, if I open a different workspace, it works sometimes. If you would like me to test anything specific let me know. Here is an example in my json file ...

Thanks for the details. This is what I'm seeing on VS Code 1.77.3 / extension v2.0.8.:

CleanShot 2023-04-13 at 21 57 42@2x

So note that the first one is OK for me, but the second is overridden by the built-in TODO: setting. You can change that in the "todohighlight.defaultStyle": {...} setting.

As you say "it works sometimes" I wonder if you or @g-berthiaume are using a single root or a "multi-root-workspace"?

@jgclark
Copy link
Owner

jgclark commented Apr 14, 2023

I've thought of something else for @g-berthiaume @RyanTheTechMan:

The include and exclude settings were ignored in all previous releases of the extension, so it's only from v2.0.8 that they started to take effect. (It seems the original author just didn't wire up those settings for some reason.)

So please check that those 2 settings look suitable for the files you're editing in VSCode.

@lukadd16
Copy link

Can confirm, after adding additional file extensions to the include setting highlights now work as expected.

Seeing as many users are probably going to be coming here with the same "problem", perhaps it'd be best to pin this issue?

@RyanTheTechMan
Copy link

I just added the following lines to my settings. Now knowing about this, it makes sense.

    "todohighlight.include": [
        // ...
        "**/*.cc",
        "**/*.cpp",
        "**/*.h",
        "**/*.json"
	]

There would be a better way to handle this though, such as detecting when to use highlights based on the language rather than or in addition to the file extensions. If this sounds good, you could use the "Language Mode" (Language Identifiers) of the file in the updateDecorations() function and have it default to a list of all the default supported languages in VS Code. (or similar)

If you would like me to make a fork, and do this myself, I absolutely can; though it will be a while since I am just entering finals week(s) at college!

@jgclark jgclark changed the title Extension stopped working with vscode v1.77.3 Extension stopped working with v2.0.8? Apr 14, 2023
@jgclark jgclark pinned this issue Apr 14, 2023
@jgclark
Copy link
Owner

jgclark commented Apr 14, 2023

Seeing as many users are probably going to be coming here with the same "problem", perhaps it'd be best to pin this issue?

Thanks for commenting and the suggestion; I've now renamed the issue slightly and pinned it.

@jgclark
Copy link
Owner

jgclark commented Apr 14, 2023

Thanks for confirming it does work when you add the (now-necessary) settings.

There would be a better way to handle this though, such as detecting when to use highlights based on the language rather than or in addition to the file extensions. If this sounds good, you could use the "Language Mode" (Language Identifiers) of the file in the updateDecorations() function and have it default to a list of all the default supported languages in VS Code. (or similar)

If you would like me to make a fork, and do this myself, I absolutely can; though it will be a while since I am just entering finals week(s) at college!

I'm looking at another possible way of addressing this in #71. However, if that doesn't work out, then yes, I'd love some help to fix this, and the old request #2 about per-language support. But, for now, focus on your finals ;-)

@g-berthiaume
Copy link
Author

As suggested by @RyanTheTechMan, adding todohighlight.include to my settings did solve my problem.

@jgclark
Copy link
Owner

jgclark commented Apr 17, 2023

A further follow-up, @RyanTheTechMan: the suggestion at #72 seems sensible to me, and looks easier than per-language settings. What do you think?

@RyanTheTechMan
Copy link

RyanTheTechMan commented Apr 17, 2023

Overall, it is definitely the easier option, since most of it is already implemented. I would definitely recommend following this suggestion in #72 so that it is more of an opt-in sort of thing.

In addition, if by default, we are wanting this to work in all languages and allow customization per language, I would suggest the following:

  • If todohighlight.codeLanguages (or another name) is not defined, use all registered VS Code languages by default.
  • If todohighlight.include is not defined, follow todohighlight.codeLanguages
  • Allow users to bypass by setting include by using **/* or setting todohighlight.everywhere to true. This is, of course, is not recommended.

Now, with help from feature request #2, todohighlight.codeLanguages can contain a list of (strings or directories), allowing the use of enabling and disabling highlights per language. todohighlight.include is then used to determine if the language should cause the highlights to show and with what new keywords to look out for.

Here is a config example:

"todohighlight.codeLanguages": [
    "c", // Equivalent to { "language": "c", "globalKeywords": true, "keywords": [] }
    "cpp", // Equivalent to { "language": "cpp", "globalKeywords": true, "keywords": [] }
    "csharp", // Equivalent to { "language": "csharp", "globalKeywords": true, "keywords": [] }
    {
        "language": "java", // Required
        "globalKeywords": false, // Defualts to true | If false, only keywords in "keywords" below will be highlighted
        "keywords": [ // Defaults to []
            {
                "text": "FIX:",
                "color": "red",
                "isWholeLine": true,
            },
        ]
    },
    {
        "language": "python", // Required
        "globalKeywords": true, // Defualts to true | If true, all keywords in "todohighlight.keywords" will be highlighted in addition to the ones in "keywords" below
        "keywords": [ // Defaults to []
            {
                "text": "WARNING:",
                "color": "yellow",
                "isWholeLine": true,
            },
        ]
    },
],

@RyanTheTechMan
Copy link

RyanTheTechMan commented Apr 17, 2023

I see that I misunderstood #2.
I think per-language support could work for keywords, however, we would lose out on "global keywords" unless it is implemented in a different way or not use "global keywords" and instead use per-language keywords if they exist.

A way to implement this approach would be an opt-out method by using Language specific editor settings.

I assume only a minimal amount of code will have to be implemented to support this in the code's current state.

Implementing todohighlight.codeLanguages would be easier to configure, but some people may like using VS Code's built-in "per-language support".

What do you think is the best way to handle this?

@alkatar21
Copy link
Collaborator

If the extension gets "per-language support", I would think it makes the most sense to use VS Code's built-in away, since that's what it's meant to do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants