aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpips.linux <Philipp.Frank@web.de>2016-04-07 21:40:40 +0200
committerKillTheMule <KillTheMule@users.noreply.github.com>2016-04-28 21:11:03 +0200
commitee4d1f2ccea1d1d6158f5781caa12dfcc1aad11d (patch)
tree6eaa041c05fa26423a035cfe11e071a16b797c21
parent81e0874a54de2213af13dda385b2c2d46cec14ae (diff)
downloadrneovim-ee4d1f2ccea1d1d6158f5781caa12dfcc1aad11d.tar.gz
rneovim-ee4d1f2ccea1d1d6158f5781caa12dfcc1aad11d.tar.bz2
rneovim-ee4d1f2ccea1d1d6158f5781caa12dfcc1aad11d.zip
vim-patch:7.4.1236
Problem: When "syntax manual" was used switching between buffers removes the highlighting. Solution: Set the syntax option without changing the value. (Anton Lindqvist) https://github.com/vim/vim/commit/885f24fbcae2a39ae496ffb3a1e139379be8fae1 Patch applied cleanly to the nvim sources except for version.c.
-rw-r--r--runtime/syntax/manual.vim11
-rw-r--r--src/nvim/version.c2
-rw-r--r--test/functional/ui/highlight_spec.lua69
3 files changed, 76 insertions, 6 deletions
diff --git a/runtime/syntax/manual.vim b/runtime/syntax/manual.vim
index 5ea373180a..c0e53fa7b4 100644
--- a/runtime/syntax/manual.vim
+++ b/runtime/syntax/manual.vim
@@ -1,6 +1,6 @@
" Vim syntax support file
" Maintainer: Bram Moolenaar <Bram@vim.org>
-" Last Change: 2008 Jan 26
+" Last Change: 2016 Feb 01
" This file is used for ":syntax manual".
" It installs the Syntax autocommands, but no the FileType autocommands.
@@ -16,10 +16,11 @@ endif
let syntax_manual = 1
-" Remove the connection between FileType and Syntax autocommands.
-if exists('#syntaxset')
- au! syntaxset FileType
-endif
+" Overrule the connection between FileType and Syntax autocommands. This sets
+" the syntax when the file type is detected, without changing the value.
+augroup syntaxset
+ au! FileType * exe "set syntax=" . &syntax
+augroup END
" If the GUI is already running, may still need to install the FileType menu.
" Don't do it when the 'M' flag is included in 'guioptions'.
diff --git a/src/nvim/version.c b/src/nvim/version.c
index b9e97f205e..d0742bfbc4 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -442,7 +442,7 @@ static int included_patches[] = {
// 1239 NA
// 1238 NA
// 1237,
- // 1236,
+ 1236,
// 1235 NA
// 1234 NA
// 1233 NA
diff --git a/test/functional/ui/highlight_spec.lua b/test/functional/ui/highlight_spec.lua
index 6a89b0983d..4b0173fa89 100644
--- a/test/functional/ui/highlight_spec.lua
+++ b/test/functional/ui/highlight_spec.lua
@@ -1,5 +1,6 @@
local helpers = require('test.functional.helpers')
local Screen = require('test.functional.ui.screen')
+local os = require('os')
local clear, feed = helpers.clear, helpers.feed
local execute, request, eq = helpers.execute, helpers.request, helpers.eq
@@ -16,6 +17,73 @@ describe('color scheme compatibility', function()
end)
end)
+describe('manual syntax highlight', function()
+ -- When using manual syntax highlighting, it should be preserved even when
+ -- switching buffers... bug did only occur without :set hidden
+ -- Ref: vim patch 7.4.1236
+ local screen
+
+ before_each(function()
+ clear()
+ screen = Screen.new(20,5)
+ screen:attach()
+ --ignore highligting of ~-lines
+ screen:set_default_attr_ignore( {{bold=true, foreground=Screen.colors.Blue}} )
+ --syntax highlight for vimcscripts "echo"
+ screen:set_default_attr_ids( {[1] = {bold=true, foreground=Screen.colors.Brown}} )
+ end)
+
+ after_each(function()
+ screen:detach()
+ os.remove('Xtest-functional-ui-highlight.tmp.vim')
+ end)
+
+ -- test with "set hidden" even if the bug did not occur this way
+ it("works with buffer switch and 'hidden'", function()
+ execute('e tmp1.vim')
+ execute('e Xtest-functional-ui-highlight.tmp.vim')
+ execute('filetype on')
+ execute('syntax manual')
+ execute('set ft=vim')
+ execute('set syntax=ON')
+ feed('iecho 1<esc>0')
+
+ execute('set hidden')
+ execute('w')
+ execute('bn')
+ execute('bp')
+ screen:expect([[
+ {1:^echo} 1 |
+ ~ |
+ ~ |
+ ~ |
+ <f 1 --100%-- col 1 |
+ ]])
+ end)
+
+ it("works with buffer switch and 'nohidden'", function()
+ execute('e tmp1.vim')
+ execute('e Xtest-functional-ui-highlight.tmp.vim')
+ execute('filetype on')
+ execute('syntax manual')
+ execute('set ft=vim')
+ execute('set syntax=ON')
+ feed('iecho 1<esc>0')
+
+ execute('set nohidden')
+ execute('w')
+ execute('bn')
+ execute('bp')
+ screen:expect([[
+ {1:^echo} 1 |
+ ~ |
+ ~ |
+ ~ |
+ <ht.tmp.vim" 1L, 7C |
+ ]])
+ end)
+end)
+
describe('Default highlight groups', function()
-- Test the default attributes for highlight groups shown by the :highlight
@@ -38,6 +106,7 @@ describe('Default highlight groups', function()
after_each(function()
screen:detach()
end)
+
it('window status bar', function()
screen:set_default_attr_ids({
[1] = {reverse = true, bold = true}, -- StatusLine