gurgeous / bust-a-gem

Adds "Go to Definition" for Ruby projects in VS Code.
https://marketplace.visualstudio.com/items?itemName=gurgeous.bust-a-gem
MIT License
36 stars 8 forks source link

Any chance the "Go to Definition" works with existing `TAGS` file while bust-a-gem is ripping new `TAGS` file? #27

Open vfonic opened 1 year ago

vfonic commented 1 year ago

I set up Bust A Gem to run whenever I save a Ruby file. It works great!

Here's my setup settings.json:

"runOnSave.commands": [
    {
      "match": "\\.(rb|rake)$",
      "command": "bust-a-gem.rebuild",
      "runIn": "vscode",
      "runningStatusMessage": "Rebuilding project tags",
      "finishStatusMessage": "Project tags rebuilt"
    }
  ],

I use this dated, but still working VS Code extension: https://marketplace.visualstudio.com/items?itemName=pucelle.run-on-save

Since my projects grew bigger and I also allow Bust A Gem to rip some gems so I can "Go to Definition" directly inside the gem files, it's taking about 3 seconds for Bust A Gem to generate TAGS file. During this time, "Go to Definition" doesn't work.

Any chance this can be changed?

If this is changed, my setup would be PERFECT! :) I could use "Go to Definition" all the time, even for new files and whenever I save a file Bust A Gem will automatically generate TAGS, but it will work all the time, except for the newly added definitions that are just being added to TAGS for the first time. Only for those I'd need to wait those ~3 seconds.

gurgeous commented 1 year ago

That's a lot of tagging, I'm impressed! In the past I've setup cron jobs to just retag once a day, but Run on Save takes the cake :) I probably won't fix this for now, but maybe I'll investigate for the next version of Bust A Gem. Thanks Viktor

vfonic commented 1 year ago

Any pointers of where I should look to fix this myself? I can create a PR and you can "take it or leave it" (I won't mind if you decide to leave it out of the official version, I just want it to work for me. :))

PS yeah, I'm impressed at the speed of tagging. It's probably two-three times faster than RuboCop. (But still two-three times too slow for me for practical use immediately after Save)

gurgeous commented 1 year ago

Sure, go for it! The code is pretty simple, though a bit out of date unfortunately. You might have to wade through some extension upgrade stuff just to get it running. The vscode extension docs are pretty good. In terms of fixing the actual problem, first we have to figure out why it doesn't work - are extensions allowed to be re-entrant? do we need to create a background process and keep an eye on it? does ctags create the file atomically, or truncate it in place? Thanks and good luck!