Closed a-bentofreire closed 1 month ago
Hi Alexandre,
Unfortunately, I cannot reproduce the problem. So if you or someone else eventually finds the way please share and I will investigate it.
Until then you can open the file list and add the path manually:
Hi, Oleg Thank you for the quick reply. I just did multiple tests and I found a situation where always happens:
This is fantastic. Sorry, I did not respond early. Will have a look at it asap.
No worries. Thank you for replying
Do I repeat the test correctly?
Somehow VSCode behaves differently...
I just made a gif to show how it happens, and it always happens doing exactly like this regardless of the files that I click.
Your test is not really different to mine. Except for the outcome :) Can this be due to the fact that you open the workspace. Unlikely, I know. And I tested it with the workspace too.
what OS are you running it on?
Hi, I also test as a folder without a workspace and the problem is the same. with a bit more time, I will try to investigate deeper into the problem. OS: Linux Mint 22 Wilma | Cinnamon 6.2.9 VSC and your extension are both in the latest version.
Hm, maybe Linux makes the diff. Will check there too
No, the same. Work OK. I am really puzzled about that.
The notation [object Object]
indicates that the it is the result of the toString()
call of some object instance. And in the _add(file)
scenario there is only one place where toString()
is called
https://github.com/oleg-shilo/Favorites.vscode/blob/cf4689d86e33c5c8d350894d9a73ef1ce09037ae/src/extension.ts#L95
But I cannot imagine how Uri
can return such a string.
If you add a few log lines in several places, zip the extension.js and place it here, I will test it.
Great. Good idea. Please take this file. It will print to the CodeMap#49 channel:
I have that issue too, if you need another tester :-)
Windows 11, VS Code 1.93
Hi Igor, this would be great. Logging will only get us so far. If I dare to ask, can you try to debug the extension? I am helpless without ability to reproduce it. And debugger would give us the unswer in a few mins.
If you indeed happy to help, just clone the repo, load it in VSCode. Put your breakpoint in the add
method and hit F5:
That's it. Now when you add the file to the list the breakpoint will be fired and you will be able to see what is happening there.
Please do not hesitate to say "No". We are all busy, I would p[perfectly understand.
Hi, Oleg Yeah, I have also been super busy with my own VSC extension.
I did test your extension just a minute ago, and the output is:
Added to the Favorites (1): [object Object]
I saved you some back and forth, and tweaked your extension.js:
function add(fileName) {
var _a, _b, _c;
let log = vscode.window.createOutputChannel("CodeMap#49");
if (fileName) {
_add(fileName);
log.appendLine(`Added to the Favorites (1): ${fileName}`);
const objString = JSON.stringify(fileName);
log.appendLine(`Added to the Favorites (2): ${objString}`);
}
and the output was:
{
"collapsibleState": 0,
"label": "Americas-Journey.md",
"command": {
"command": "favorites.open",
"title": "",
"tooltip": "/home/abf/Americas-Journey.md",
"arguments": [
"/home/abf/Americas-Journey.md"
]
},
"children": null,
"context": "/home/abf/Americas-Journey.md",
"rootFolder": false,
"contextValue": "file",
"tooltip": "/home/abf/Americas-Journey.md",
"resourceUri": {
"$mid": 1,
"path": "/home/abf/Americas-Journey.md",
"scheme": "file"
},
"iconPath": null
}
I would suggest on the if to check if it's a string, and if not use the filename['resourceUri']['path']
, I'm guessing that must obvious for you now.
Fantastic, thank you Alexandre Will do the fix on weekend
Awesome, looking forward.
This is really strange as your debug info proves that function add(fileName: string)
instead of a string argument receives FavoriteItem
. This method is a root-level method in the call stack as it is invoked by VSCode only:
So I have no idea how this substitution can happen.
Anyway, your suggested workaround will address the issue. Thank you.
The release v1.6.1 with the fix has been published.
I just tried the new version and now there is a new issue. It doesn't lets me add any new document. When I do the same procedure as my early gif, it will report: "The active document is already in the Favorites."
I have been using your extension for quite a while and before it didn't have this issue, it's a recent update that cause it, probably of vscode.
I GOT IT!!! The original problem. After the last VSCode update I have it too. Great. Meaning I will be able to reproduce it. Probably I just missed that VSCode update.
Working on it.
I checked on two systems now and it shows a consistent result with the older version of the extension without Alexandre's workaround.. VSCode v1.92.2 works just fine. And the latest update to v1.93.1 breaks it.
After updating the extension the problem is gone and indeed a new one surfaced. Related to the duplication due to that resourceUri.path
pointing to the last open document but not the active one. Though on Win the error itself is slightly different but the cause is the same (I believe).
While now I am convinced it is a VSCode problem, it's a very little comfort for the users. I'll see if I can find another workaround.
In the mean while avoid using the +
button and use the command instead. It seems to work correctly:
Done, the extension v1.6.3 has an alternative workaround that seems to address the issue. Please let me know if it indeed does. . . . These are my findings:
This is the extension root level function as it was before the fix:
function add(fileName: string) {
if (fileName) {
// The function is called by another extension function `add_file` that passes a string as an arg
// add fileName to favs
. . .
}
else {
// The function is called by VSCode shell (fileName is null)
// add active doc to favs
. . .
}
}
VSCode v1.92.2 always passed null if the method is invoked by the VSCode shell. Easy. Though at least from v1.93.1 they started passing the Favorites explorer selected mode. And this obviously breaks the logic.
Now it's fixed by explicit checking of fileName
for being a string type.
Sounds like you were thrilled about it. I already checked and all it seems good now. Great job! I'm going to close the issue, I will reopen if I find some.
Hi, I'm using Favorites 1.6.0, when I click on icon "+" quite often instead of the filename being added, it adds [object Object]. Sometimes adds the correct filename but most times doesn't. I couldn't find a pattern to determine when it generates the correct filename, and when it doesn't. I'm using the latest version of VSCode on Linux.