" MIT License. Copyright (c) 2013-2021 Bailey Ling, Christian Brabandt et al.
" Plugin: https://github.com/chrisbra/NrrwRgn
" vim: et ts=2 sts=2 sw=2

scriptencoding utf-8

if !get(g:, 'loaded_nrrw_rgn', 0)
  finish
endif

function! airline#extensions#nrrwrgn#apply(...)
  if exists(":WidenRegion") == 2
    let spc = g:airline_symbols.space
    if !exists("*nrrwrgn#NrrwRgnStatus()") || empty(nrrwrgn#NrrwRgnStatus())
      call a:1.add_section('airline_a', printf('%s[Narrowed%s#%d]', spc, spc, b:nrrw_instn))
      let bufname=(get(b:, 'orig_buf', 0) ? bufname(b:orig_buf) : substitute(bufname('%'), '^Nrrwrgn_\zs.*\ze_\d\+$', submatch(0), ''))
      call a:1.add_section('airline_c', spc.bufname.spc)
      call a:1.split()
    else
      let dict=nrrwrgn#NrrwRgnStatus()
      let vmode = { 'v': 'Char ', 'V': 'Line ', '