BigBahss / vscode-cmantic

C/C++ code generation for VS Code: Generate Definitions, Getters, Setters, and much more.
https://bigbahss.github.io/vscode-cmantic/
MIT License
83 stars 9 forks source link

'Add Definition' sometimes doesn't reveal the function #2

Open BigBahss opened 3 years ago

BigBahss commented 3 years ago

The 'Add Definition' commands sometimes don't properly reveal the inserted function (The editor doesn't scroll all the way to where the function was inserted). This seems to only happen for large files with a lot of DocumentSymbols, and it is unclear why. I've spent a good amount of time trying to debug and fix this problem, and it doesn't seem to be a problem in the C-mantic code. The Range passed to TextEditor.revealRange() is always correct, but the editor doesn't always scroll to that range. The editor does scroll in the direction of the function, but only a little bit. I haven't found consistent setup to reproduce the problem, other than that it only happens for large files. Also, this happens for ms-vscode.cpptools, clangd, and ccls, so it doesn't seem to be a problem with the language server. I'm considering opening an issue with vscode. If I do I'll link it here.

BigBahss commented 3 years ago

I noticed this can happen in other extensions, specifically gruntfuggly.todo-tree, so this must be a bug in vscode.

BigBahss commented 3 years ago

Release 0.4.0 has a workaround for this issue that sets a 500ms timeout and checks if the editor actually revealed the range, and if not it will try it again. If the first one didn't work, the second one usually does. I have noticed that the second one can still fail, but this improves the issue a lot. Leaving open for now.