Skip to content

Commit

Permalink
Allow opening log in hidden buffer even when hidden is unset
Browse files Browse the repository at this point in the history
  • Loading branch information
insidewhy committed Nov 21, 2021
1 parent 88d9324 commit 2b3d56f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ are saved; defaults to `1`.
* `g:flutter_hot_restart_on_save` - Whether to auto hot-restart when `dart` files
are saved; defaults to `0`.
* `g:flutter_show_log_on_run` - Automatically open `__Flutter_Output__` when starting
flutter; defaults to `1`. Setting this to 0 requires `set hidden` in your vimrc. It may
also be set to `"tab"` to open the log in a new tab rather than splitting the window.
flutter; it can have one of the following values:
* `"split"` or `1`: Open the log in a split, this is the default.
* `"tab"`: Open the log in a new tab.
* `"hidden"` or `0`: Do not open the log by default, can be opened later with `FlutterSplit` etc.
* `g:flutter_autoscroll` - Autoscroll the flutter log when `1`, defaults to `0`.

## Provided Commands
Expand Down
25 changes: 13 additions & 12 deletions autoload/flutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,19 @@ function! flutter#run(...) abort
return 0
endif

if g:flutter_show_log_on_run || type(g:flutter_show_log_on_run) == v:t_string
if g:flutter_show_log_on_run == "tab"
" open new tab and move it before the current tab
tabnew __Flutter_Output__
tabm -1
else
split __Flutter_Output__
endif
normal! ggdG
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal noswapfile
if g:flutter_show_log_on_run == "tab" || g:flutter_show_log_on_run == "hidden"
" open new tab and move it before the current tab
tabnew __Flutter_Output__
tabm -1
else
split __Flutter_Output__
endif
normal! ggdG
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal noswapfile
if g:flutter_show_log_on_run == "hidden"
tabclose
endif

let cmd = g:flutter_command.' run'
Expand Down
9 changes: 4 additions & 5 deletions plugin/flutter.vim
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,10 @@ if !exists('g:flutter_use_last_run_option')
let g:flutter_use_last_run_option=0
endif

if !exists('g:flutter_show_log_on_run')
let g:flutter_show_log_on_run=1
elseif &hidden == 0 && g:flutter_show_log_on_run == 0 && type(g:flutter_show_log_on_run) != v:t_string
echoerr "WARNING: Hidden buffers are disabled. Setting g:flutter_show_log_on_run to 1. Please add `set hidden` to your vimrc to keep the flutter log in the background."
let g:flutter_show_log_on_run = 1
if !exists('g:flutter_show_log_on_run') || g:flutter_show_log_on_run == 1
let g:flutter_show_log_on_run="split"
elseif type(g:flutter_show_log_on_run) == v:t_number && g:flutter_show_log_on_run == 0
let g:flutter_show_log_on_run="hidden"
endif

command! FlutterDevices call flutter#devices()
Expand Down

0 comments on commit 2b3d56f

Please sign in to comment.