derekwyatt / vim-fswitch

Vim plug for switching between companion source files (e.g. ".h" and ".cpp")
179 stars 57 forks source link

This plugin may be loaded twice if the plugin file appears in the runtime path twice #4

Closed xuhdev closed 12 years ago

xuhdev commented 12 years ago

This problem can be easily solved by adding the following lines to the beginning of the plugin/fswitch.vim file:

    if exists('g:fswitch_loaded')
          finish
    endif
    let g:fswitch_loaded = 1
derekwyatt commented 12 years ago

Naw, I hate that stuff. When working with the plugin it's really annoying to not have it reload. I've /never/ encountered a time when this was a problem, and neither has anyone else. However, what you have here would be a problem every time I wanted to modify the file. Further, if you've got it in your path twice, then you've got another problem... which one loads first? Clearly the person who has two, has a problem, and they need to fix that problem, not have us hide it like this.

The real reason that people do this is to make it skip parsing the file if it's ever loaded again so that it's "fast". But this script is so small that speed isn't a problem.

xuhdev commented 12 years ago

The loading sequence is according to runtimepath: the one first appears in runtimepath will be loaded first, and the one last appears will be loaded last. I could have a tip version somewhere other than the default runtime location, and prepend that location in runtimepath -- convenient for development. So it would still be useful for this snippets.

derekwyatt commented 12 years ago

Oh I know how it works. What I'm saying is that your 80/20 is way off. The way it is now, I get a huge amount of benefit and a small amount of inconvenience (actually, small = 0 here... nobody's complained yet and no real-world issue has shown up). What you're saying is to make a change so that now there's a ton of inconvenience and no benefit - i.e. no "real world" case of multiple copies in the runtimepath.

Practically speaking, this change would introduce a bug.

xuhdev commented 12 years ago

I do not know what your "real world" means, but I have explained the situation I met, otherwise I won't find this problem. Could you explain what is the benefit and what is the bug, please?

derekwyatt commented 12 years ago

"real world" = happens with a certain amount of regularity.

What you've described could theoretically happen but I have zero reports of it happening, and it never happens to me. But, what I do regularly is modify the script and reload it. If I put this "fix" in there then all I would have is a pain in the ass... hence the "bug". Real world vs. theory? Theory loses.