Skip to content

Commit

Permalink
Fix bugs related to reconnecting
Browse files Browse the repository at this point in the history
Disconnect and reconnecting works:
```
:IcedConnect | IcedDisconnect | IcedConnect
```

Makes `:IcedReconnect` work if a connection is not already established.
  • Loading branch information
matthias-margush committed Jan 4, 2019
1 parent 3dafa10 commit ad5875f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions autoload/iced/di/channel/neovim.vim
Expand Up @@ -36,6 +36,7 @@ function! s:ch.open(address, options) abort
endfunction

function! s:ch.close(handler) abort
let self['is_connected'] = v:false
return chanclose(s:ch_id(a:handler))
endfunction

Expand Down
9 changes: 6 additions & 3 deletions autoload/iced/nrepl.vim
Expand Up @@ -88,7 +88,7 @@ endfunction
" HANDLER {{{
function! s:get_message_id(x) abort
let x = a:x
if type(x) == type([])
if type(x) == type([]) && len(x) > 0
let x = x[0]
endif
if type(x) == type({})
Expand Down Expand Up @@ -321,12 +321,15 @@ function! iced#nrepl#disconnect() abort " {{{
call iced#nrepl#sync#close(id)
endfor
call iced#di#get('channel').close(s:nrepl['channel'])
call s:initialize_nrepl()
let s:nrepl = s:initialize_nrepl()
call iced#cache#clear()
call iced#message#info('disconnected')
endfunction " }}}

function! iced#nrepl#reconnect() abort " {{{
if !iced#nrepl#is_connected() | return | endif
if !iced#nrepl#is_connected()
return iced#nrepl#connect#auto()
endif

let port = s:nrepl['port']
call iced#nrepl#disconnect()
Expand Down
1 change: 1 addition & 0 deletions message/iced/en.txt
Expand Up @@ -6,6 +6,7 @@
'not_connected': 'Not connected.',
'try_connect': 'Not connected. Try `:IcedConnect <port>`',
'connected': 'Connected.',
'disconnected': 'Disconnected.',
'interrupted': 'Interrupted.',
'reading': 'Still reading..',
'not_found': 'Not found.',
Expand Down

0 comments on commit ad5875f

Please sign in to comment.