diff --git a/README.md b/README.md index c077bd126..19a4fa1a4 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ [![Build Status](https://travis-ci.org/SpaceVim/SpaceVim.svg?branch=master)](https://travis-ci.org/SpaceVim/SpaceVim) [![Build status](https://ci.appveyor.com/api/projects/status/eh3t5oph70abp665/branch/master?svg=true)](https://ci.appveyor.com/project/wsdjeg/spacevim/branch/master) +[![codecov](https://codecov.io/gh/SpaceVim/SpaceVim/branch/master/graph/badge.svg)](https://codecov.io/gh/SpaceVim/SpaceVim/branch/master) [![Docker Build Status](https://img.shields.io/docker/build/spacevim/spacevim.svg)](https://hub.docker.com/r/spacevim/spacevim/) ![Version](https://img.shields.io/badge/version-1.6.0--dev-8700FF.svg) [![GPLv3 License](https://img.shields.io/badge/license-GPLv3-blue.svg)](LICENSE) diff --git a/autoload/SpaceVim/api/vim/buffer.vim b/autoload/SpaceVim/api/vim/buffer.vim index 4faa28586..e7cf0281d 100644 --- a/autoload/SpaceVim/api/vim/buffer.vim +++ b/autoload/SpaceVim/api/vim/buffer.vim @@ -277,7 +277,11 @@ function! s:self.displayArea() abort endfunction function! s:self.add_highlight(bufnr, hl, line, col, long) abort - + if exists('*nvim_buf_add_highlight') + call nvim_buf_add_highlight(a:bufnr, 0, a:hl, a:line, a:col, a:col + a:long) + else + call SpaceVim#logger#warn('vim#buffer.add_highlight api only support neovim', 0) + endif endfunction function! s:self.buf_get_lines(bufnr, start, end, strict_indexing) abort @@ -295,7 +299,7 @@ function! s:self.buf_get_lines(bufnr, start, end, strict_indexing) abort if !bufloaded(a:bufnr) call bufload(a:bufnr) endif - return getbufline(a:bufnr, a:start + 1, a:end + 1) + return getbufline(a:bufnr, a:start + 1, a:end) elseif a:start >= 0 && a:end < 0 && lct + a:end >= a:start return self.buf_get_lines(a:bufnr, a:start, lct + a:end + 1, a:strict_indexing) elseif a:start <= 0 && a:end > a:start && a:end < 0 && lct + a:start >= 0 diff --git a/test/api/vim/buffer.vader b/test/api/vim/buffer.vader index 32b6d7914..007077880 100644 --- a/test/api/vim/buffer.vader +++ b/test/api/vim/buffer.vader @@ -24,17 +24,12 @@ Execute ( SpaceVim api: vim#buffer buf_set_lines): unlet nr unlet buffer -Execute ( SpaceVim api: vim#buffer add_highlight): - let buffer = SpaceVim#api#import('vim#buffer') - let highlit = SpaceVim#api#import('vim#highlight') - let nr = buffer.bufnr() - call buffer.add_highlight(nr,'String', 1, 1, 1) - AssertEqual highlit.syntax_at(1, 1), 'String' - Execute ( SpaceVim api: vim#buffer buf_get_lines): let buffer = SpaceVim#api#import('vim#buffer') let nr = buffer.bufadd('') call setbufvar(nr, '&buftype', 'nofile') call setbufvar(nr, '&buflisted', 0) call buffer.buf_set_lines(nr, 0, 1, 0, ['line 1', 'line 2', 'line 3', 'line 4']) - AssertEqual buffer.buf_get_lines(nr, 1, 2, 0), ['line 2'] + if has('patch-8.1.1610') + AssertEqual buffer.buf_get_lines(nr, 1, 2, 0), ['line 2'] + endif