1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-03 01:50:05 +08:00

fix(protocal): keep protocal when fail to switch

This commit is contained in:
wsdjeg 2022-05-03 22:00:28 +08:00
parent a7fa0c73ed
commit 992ffadef3

View File

@ -379,6 +379,7 @@ function! s:enter() abort
let s:c_begin = '' let s:c_begin = ''
return return
elseif s:c_begin . s:c_char . s:c_end =~# '/set_protocol\s*' elseif s:c_begin . s:c_char . s:c_end =~# '/set_protocol\s*'
let saved_protocal = s:protocol
let s:protocol = matchstr(s:c_begin . s:c_char . s:c_end, '/set_protocol\s*\zs\S*') let s:protocol = matchstr(s:c_begin . s:c_char . s:c_end, '/set_protocol\s*\zs\S*')
let s:c_end = '' let s:c_end = ''
let s:c_char = '' let s:c_char = ''
@ -389,6 +390,15 @@ function! s:enter() abort
let s:opened_channels[s:protocol] = [] let s:opened_channels[s:protocol] = []
endif endif
catch catch
call chat#windows#push({
\ 'user' : '--->',
\ 'username' : '--->',
\ 'room' : '',
\ 'protocol' : s:protocol,
\ 'msg' : 'protocal does not exists: ' . s:current_channel,
\ 'time': strftime("%Y-%m-%d %H:%M"),
\ })
let s:protocol = saved_protocal
endtry endtry
call s:update_msg_screen() call s:update_msg_screen()
return return
@ -410,7 +420,7 @@ function! s:enter() abort
\ 'username' : '--->', \ 'username' : '--->',
\ 'room' : saved_channel, \ 'room' : saved_channel,
\ 'protocol' : s:protocol, \ 'protocol' : s:protocol,
\ 'msg' : 'can not find channel:' . s:current_channel, \ 'msg' : 'channel does not exists: ' . s:current_channel,
\ 'time': strftime("%Y-%m-%d %H:%M"), \ 'time': strftime("%Y-%m-%d %H:%M"),
\ }) \ })
let s:current_channel = saved_channel let s:current_channel = saved_channel