diff options
| author | Frank LENORMAND <lenormf@gmail.com> | 2019-07-23 13:09:41 +0300 |
|---|---|---|
| committer | Frank LENORMAND <lenormf@gmail.com> | 2019-07-25 12:28:04 +0300 |
| commit | da2f6c296ae3ee280ffaca3937c6ae35c78d1e38 (patch) | |
| tree | 99a0aebefcddaf2b109c2fc4eb7e29af9b52bd01 /src/string_utils.hh | |
| parent | e42c81c8eb53a6562f0d7313a6a9a92d8360238f (diff) | |
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
Diffstat (limited to 'src/string_utils.hh')
| -rw-r--r-- | src/string_utils.hh | 1 |
1 files changed, 1 insertions, 0 deletions
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); |
