Skip to content

Commit 41eacd9

Browse files
committed
docs(diff): clarify buffer summary if there is no reference text
Related to #2082
1 parent 64a23d0 commit 41eacd9

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

doc/mini-diff.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,17 +203,18 @@ Each enabled buffer has the following buffer-local variables which can be
203203
used in custom statusline to show an overview of hunks in current buffer:
204204

205205
- `vim.b.minidiff_summary` is a table with the following fields:
206-
- `source_name` - name of the active source.
206+
- `source_name` - name of the active source. This is the only present field
207+
if buffer's reference text is not (yet) set.
207208
- `n_ranges` - number of hunk ranges (sequences of contiguous hunks).
208209
- `add` - number of added lines.
209210
- `change` - number of changed lines.
210211
- `delete` - number of deleted lines.
211212

212213
- `vim.b.minidiff_summary_string` is a string representation of summary
213-
with a fixed format. It is expected to be used as is. To achieve
214-
different formatting, use `vim.b.minidiff_summary` to construct one.
215-
The best way to do this is by overriding `vim.b.minidiff_summary_string`
216-
in the callback for |MiniDiff-update-event| event: >lua
214+
with a fixed format. Empty string if there is no reference text (yet).
215+
It is expected to be used as is. To achieve different formatting, use
216+
`vim.b.minidiff_summary` to construct one. The best way to do this is by
217+
overriding `vim.b.minidiff_summary_string` inside |MiniDiff-update-event|: >lua
217218

218219
local format_summary = function(data)
219220
local summary = vim.b[data.buf].minidiff_summary

lua/mini/diff.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,17 +200,18 @@
200200
--- used in custom statusline to show an overview of hunks in current buffer:
201201
---
202202
--- - `vim.b.minidiff_summary` is a table with the following fields:
203-
--- - `source_name` - name of the active source.
203+
--- - `source_name` - name of the active source. This is the only present field
204+
--- if buffer's reference text is not (yet) set.
204205
--- - `n_ranges` - number of hunk ranges (sequences of contiguous hunks).
205206
--- - `add` - number of added lines.
206207
--- - `change` - number of changed lines.
207208
--- - `delete` - number of deleted lines.
208209
---
209210
--- - `vim.b.minidiff_summary_string` is a string representation of summary
210-
--- with a fixed format. It is expected to be used as is. To achieve
211-
--- different formatting, use `vim.b.minidiff_summary` to construct one.
212-
--- The best way to do this is by overriding `vim.b.minidiff_summary_string`
213-
--- in the callback for |MiniDiff-update-event| event: >lua
211+
--- with a fixed format. Empty string if there is no reference text (yet).
212+
--- It is expected to be used as is. To achieve different formatting, use
213+
--- `vim.b.minidiff_summary` to construct one. The best way to do this is by
214+
--- overriding `vim.b.minidiff_summary_string` inside |MiniDiff-update-event|: >lua
214215
---
215216
--- local format_summary = function(data)
216217
--- local summary = vim.b[data.buf].minidiff_summary

0 commit comments

Comments
 (0)