diff options
| author | Victor S <victorplentz@gmail.com> | 2023-10-04 19:25:19 -0300 |
|---|---|---|
| committer | Victor S <victorplentz@gmail.com> | 2023-10-04 19:25:19 -0300 |
| commit | c194baf8b30a27ed0075ca0eece270431bdaa913 (patch) | |
| tree | 824a366a0603078a19f9d43aaef48405ffd84c5f /autoload/prettier/utils | |
| parent | 5e6cca21e12587c02e32a06bf423519eb1e9f1b2 (diff) | |
| download | vim-prettier-c194baf8b30a27ed0075ca0eece270431bdaa913.tar.xz | |
refactor: split range getter into two parts
Split the function that returns the visual selection range into two parts that
return the start and the end of the range respectively, and use them in the
CLI-command composer. This is part of a plan to use a general object with
details about flags to compose the CLI command.
Diffstat (limited to 'autoload/prettier/utils')
| -rw-r--r-- | autoload/prettier/utils/buffer.vim | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/autoload/prettier/utils/buffer.vim b/autoload/prettier/utils/buffer.vim index 3125bcc..922a0db 100644 --- a/autoload/prettier/utils/buffer.vim +++ b/autoload/prettier/utils/buffer.vim @@ -61,10 +61,12 @@ function! s:getCharPosition(line, col) abort return line2byte(a:line) + (a:col - 2) endfun -" Returns [start, end] byte range when on visual mode -function! prettier#utils#buffer#getCharRange(startSelection, endSelection) abort - let l:range = [] - call add(l:range, s:getCharPosition(a:startSelection, col("'<"))) - call add(l:range, s:getCharPosition(a:endSelection, col("'>"))) - return l:range +" Return the start byte when on visual mode +function! prettier#utils#buffer#getCharRangeStart(startSelection) abort + return s:getCharPosition(a:startSelection, col("'<")) +endfunction + +" Return the end byte when on visual mode +function! prettier#utils#buffer#getCharRangeEnd(endSelection) abort + return s:getCharPosition(a:endSelection, col("'>")) endfunction |
