MattiasPernhult / vscode-todo

Lists TODO:s in the project
Other
44 stars 19 forks source link

extension stops working if binary files are present 🐛 #40

Open delibytes opened 7 years ago

delibytes commented 7 years ago

Hello! First of all thank you for this great extension! 👍 💎 Usually it is working great, but recently it stopped working after adding woff2-files, which are binary files.

Problem

The reason is in helper.js in function findTodosinFiles when calling Workspace.openTextDocument. For binary files the promise is called with an undefined object.

Solution

I solved it by adding an if-statement in the promise:

var findTodosinFiles = function(files, choosenLanguage, scanRegex, done) {
    ...
    if (files.length === 0) {
        ...
    } else {
        for (var i = 0; i < files.length; i++) {
        Workspace.openTextDocument(files[i]).then(function(file) {
            if (file) { // <-- line added
                findTodosinSpecifiedFile(file, todos, todosList, scanRegex);
            } // <-- line added

see helper.js line 93.

Workaround

Of course, someone can add binary file extensions to "todoIgnore" in the user settings like so:

"todoIgnore":   ["node_modules/**", ... , "**/*.woff2"]

I kindly ask you to fix it. 🙇 😉 Best regards, Harald

raucha commented 7 years ago

+1 I love this great extension too and strongly wish this problem will be solved.

For now , I've make my this extension work by editting ~/.vscode/extensions/MattiasPernhult.vscode-todo-0.8.0/helper.js as @delibytes says. Thank you!

bruceauyeung commented 7 years ago

+1 @delibytes i suggest you file a PR, i will be watching :)

MaverickMartyn commented 7 years ago

This is fixed in my fork called vscode-todo-renewed. I created it since the author seems to have abandoned the project.