aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-07-23 00:21:21 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-07-23 00:21:21 +1200
commit0c0163d734b2fd63cfebce8b7a76f103d24498ed (patch)
tree5420e48c3b0fbab401378972d7925d4b698e7432
parentRefactor autoload function to reduce indents (diff)
downloadvim-alternate-filetypes-0c0163d734b2fd63cfebce8b7a76f103d24498ed.tar.gz
vim-alternate-filetypes-0c0163d734b2fd63cfebce8b7a76f103d24498ed.zip
Do nothing if the filetype won't change
This avoids reloading the ftplugin when the user likely doesn't want that.
-rw-r--r--autoload/alternate_filetypes.vim5
1 files changed, 4 insertions, 1 deletions
diff --git a/autoload/alternate_filetypes.vim b/autoload/alternate_filetypes.vim
index 18bc6d4..713015f 100644
--- a/autoload/alternate_filetypes.vim
+++ b/autoload/alternate_filetypes.vim
@@ -20,6 +20,9 @@ function! alternate_filetypes#() abort
" Switch to the next filetype, or the first filetype if the current
" filetype is the last in the list
"
- let &filetype = filetypes[ (index + 1) % len(filetypes) ]
+ let filetype = filetypes[ (index + 1) % len(filetypes) ]
+ if &filetype != filetype
+ let &filetype = filetype
+ endif
endfunction