Hello Vim developers; attached are two small patches for issues peculiar
to negative values for 'softtabstop'; a code comment correction, and a
change to correct what seems like a bug introduced by the new +vartabs
feature that meant that the number of spaces to insert was incorrectly
falling back to a value from 'tabstop'.
--
Tom Ryder <https://sanctum.geek.nz/>
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.
>From f4937ab0ca5a85d2ed4c19e21c8643e7fba4f5fb Mon Sep 17 00:00:00 2001
From: Tom Ryder <[email protected]>
Date: Sat, 30 Jun 2018 17:11:45 +1200
Subject: [PATCH 1/2] Correct a comment on negative 'softtabstop'
When 'softtabstop' is negative, the value of 'shiftwidth' is used, not
the value of 'tabstop' as this comment asserted.
---
src/option.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/option.c b/src/option.c
index 50d42ebf7..504b92a71 100644
--- a/src/option.c
+++ b/src/option.c
@@ -13016,7 +13016,7 @@ get_sw_value(buf_T *buf)
/*
* Return the effective softtabstop value for the current buffer, using the
- * 'tabstop' value when 'softtabstop' is negative.
+ * 'shiftwidth' value when 'softtabstop' is negative.
*/
long
get_sts_value(void)
--
2.18.0
>From 5576dabd711e7eb2f3c9810aa5a10e056c18273b Mon Sep 17 00:00:00 2001
From: Tom Ryder <[email protected]>
Date: Sat, 30 Jun 2018 17:29:22 +1200
Subject: [PATCH 2/2] Correct 'softtabstop' checking with +vartabs
When +vartabs is enabled, on an insert mode tab key press, src/edit.c
tests for a "set" value of 'softtabstop' if it's greater than zero. This
was introduced in 8.1.0105.
However, since 7.3.693, 'softtabstop' can also be set to a negative
value, in which case the value of 'shifwidth' is used. This was the
basis of the get_sts_value() wrapper function implemented in
src/option.c.
This meant that for users with 'softtabstop' set to a negative value,
since 8.1.0105, 'tabstop' spaces were inserted on each tab press, even
though 'varsofttabstop' is blank.
This change corrects both the boolean check for whether the option is
set to a non-zero value, and also the retrieval of the final correct
number of actual spaces to insert in lieu of a tab character, using the
helper function.
---
src/edit.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/edit.c b/src/edit.c
index d4de825af..73bf9f302 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -10203,9 +10203,9 @@ ins_tab(void)
temp = (int)curbuf->b_p_sw;
temp -= get_nolist_virtcol() % temp;
}
- else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts > 0)
+ else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts != 0)
/* use 'softtabstop' when set */
- temp = tabstop_padding(get_nolist_virtcol(), curbuf->b_p_sts,
+ temp = tabstop_padding(get_nolist_virtcol(), get_sts_value(),
curbuf->b_p_vsts_array);
else /* otherwise use 'tabstop' */
temp = tabstop_padding(get_nolist_virtcol(), curbuf->b_p_ts,
--
2.18.0