From da2f6c296ae3ee280ffaca3937c6ae35c78d1e38 Mon Sep 17 00:00:00 2001 From: Frank LENORMAND Date: Tue, 23 Jul 2019 13:09:41 +0300 Subject: src: De-indent docstrings passed to command/option/mapping definitions This commit implements formatting behaviour when the first character of a docstring is a newline. In that case, the exact indentation level of the next line will be removed from that line and all subsequent non-empty lines. An error will be returned if a subsequent non-empty line does not have the same indentation level. The docstrings are always trimmed (surrounding whitespaces) whether the first character is a newline or not, as was the case prior to this commit. Example: the following declaration ``` define-command test -docstring %{ test: do something Nothing really. More indented lines. } nop ``` would be rendered as ``` test: do something Nothing really. More indented lines. ``` Related to #2405 --- src/string_utils.hh | 1 + 1 file changed, 1 insertion(+) (limited to 'src/string_utils.hh') diff --git a/src/string_utils.hh b/src/string_utils.hh index 928070d3..9c31d767 100644 --- a/src/string_utils.hh +++ b/src/string_utils.hh @@ -10,6 +10,7 @@ namespace Kakoune { StringView trim_whitespaces(StringView str); +String trim_indent(StringView str); String escape(StringView str, StringView characters, char escape); String unescape(StringView str, StringView characters, char escape); -- cgit v1.2.3