Skip to content

Commit

Permalink
Better exception handling on Ttoggle
Browse files Browse the repository at this point in the history
  • Loading branch information
kassio committed Nov 5, 2020
1 parent e24d0ed commit 7846193
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### 05/11/2020
- Better exception handling when toggling neoterm and it's the last open
window.
### 23/09/2020
- Add `jupyter console` as a valid python REPL.

Expand Down
28 changes: 14 additions & 14 deletions autoload/neoterm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,8 @@ function! neoterm#close(...) abort
end

call neoterm#origin#return(l:instance.origin)
catch /^Vim\%((\a\+)\)\=:E444/
if len(getbufinfo()) == 1
echoe 'neoterm is the only opened window. To close it use `:Tclose!`'
end

call neoterm#origin#return(l:instance.origin, 'buffer')
catch /.*E444/
throw 'Error: neoterm is the only opened window. To close it use `:Tclose!`'
endtry
end
endfunction
Expand Down Expand Up @@ -117,7 +113,11 @@ function! neoterm#toggle(...) abort
call neoterm#new(l:opts)
else
if bufwinnr(l:instance.buffer_id) > 0
call neoterm#close(l:opts)
try
call neoterm#close(l:opts)
catch
echoe v:exception
endtry
else
call neoterm#open(l:opts)
end
Expand Down Expand Up @@ -240,13 +240,13 @@ function! neoterm#destroy(instance) abort
endfunction

function! neoterm#list_ids() abort
echom 'Open neoterm ids:'
for id in keys(g:neoterm.instances)
echom printf('ID: %s | name: %s | bufnr: %s',
\ id,
\ g:neoterm.instances[id].name,
\ g:neoterm.instances[id].buffer_id)
endfor
echom 'Open neoterm ids:'
for id in keys(g:neoterm.instances)
echom printf('ID: %s | name: %s | bufnr: %s',
\ id,
\ g:neoterm.instances[id].name,
\ g:neoterm.instances[id].buffer_id)
endfor
endfunction

function! s:create_window(instance) abort
Expand Down

0 comments on commit 7846193

Please sign in to comment.