diff options
author | Gary Johnson <garyjohn@spocom.com> | 2024-06-01 20:51:33 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2024-06-01 20:51:33 +0200 |
commit | 88d4f255b7b7a19bb4f6489e0ad0956e47d51fed (patch) | |
tree | 6d81fd5e8675a167ca253375b26b13f8f2e0f86c /src/proto/indent.pro | |
parent | e299591498a20c5c587364e4df57f947dfc02897 (diff) |
patch 9.1.0456: Left shift is incorrect with vartabstop and shiftwidth=0v9.1.0456
Problem: Left shift is incorrect with vartabstop and shiftwidth=0
Solution: make tabstop_at() function aware of shift direction
(Gary Johnson)
The problem was that with 'vartabstop' set and 'shiftwidth' equal 0,
left shifts using << were shifting the line to the wrong column. The
tabstop to the right of the first character in the line was being used
as the shift amount instead of the tabstop to the left of that first
character.
The reason was that the tabstop_at() function always returned the value
of the tabstop to the right of the given column and was not accounting
for the direction of the shift.
The solution was to make tabstop_at() aware of the direction of the
shift and to choose the tabtop accordingly.
A test was added to check this behavior and make sure it doesn't
regress.
While at it, also fix a few indentation/alignment issues.
fixes: #14864
closes: #14887
Signed-off-by: Gary Johnson <garyjohn@spocom.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src/proto/indent.pro')
-rw-r--r-- | src/proto/indent.pro | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/proto/indent.pro b/src/proto/indent.pro index bafcefc677..6e56a0e370 100644 --- a/src/proto/indent.pro +++ b/src/proto/indent.pro @@ -1,15 +1,15 @@ /* indent.c */ int tabstop_set(char_u *var, int **array); int tabstop_padding(colnr_T col, int ts_arg, int *vts); -int tabstop_at(colnr_T col, int ts, int *vts); +int tabstop_at(colnr_T col, int ts, int *vts, int left); colnr_T tabstop_start(colnr_T col, int ts, int *vts); void tabstop_fromto(colnr_T start_col, colnr_T end_col, int ts_arg, int *vts, int *ntabs, int *nspcs); int *tabstop_copy(int *oldts); int tabstop_count(int *ts); int tabstop_first(int *ts); long get_sw_value(buf_T *buf); -long get_sw_value_indent(buf_T *buf); -long get_sw_value_col(buf_T *buf, colnr_T col); +long get_sw_value_indent(buf_T *buf, int left); +long get_sw_value_col(buf_T *buf, colnr_T col, int left); long get_sts_value(void); int get_indent(void); int get_indent_lnum(linenr_T lnum); |