tpope / vim-fireplace

fireplace.vim: Clojure REPL support
https://www.vim.org/scripts/script.php?script_id=4978
1.75k stars 139 forks source link

Register port file after connecting to port #169

Closed ghost closed 10 years ago

ghost commented 10 years ago

It's currently possible to add a port file to s:repl_portfiles that doesn't have a connection key (ie. when trying to eval something in a project that still has an old .nrepl-port in it).

Unfortunately, there's a couple places that expect that connection key to be there, leading to a Vim(call):E716: Key not present in Dictionary: connect) error on any subsequent eval, even if the REPL does get started.

This pull fixes this behaviour by only adding an entry into s:repl_portfiles after successfully connecting to the REPL.

An alternative fix would have been to guard each of those dictionary accesses with has_key(..., 'connection') but then the port file would get registered once and then would never get tried again, even after the REPL has started. The solution submitted above makes more sense to me.

tpope commented 10 years ago

This happened to me the other day but I gave up on tracking it down. Good work.