aboutsummaryrefslogtreecommitdiff
path: root/autoload/prettier/utils
diff options
context:
space:
mode:
authorVictor S <victorplentz@gmail.com>2023-10-04 19:25:19 -0300
committerVictor S <victorplentz@gmail.com>2023-10-04 19:25:19 -0300
commitc194baf8b30a27ed0075ca0eece270431bdaa913 (patch)
tree824a366a0603078a19f9d43aaef48405ffd84c5f /autoload/prettier/utils
parent5e6cca21e12587c02e32a06bf423519eb1e9f1b2 (diff)
downloadvim-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.vim14
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