-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Add support for multi-file edits #2359
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
To help push progress, I am describing the changes introduced in this PR in more detail below.
Please let me know if I can implement some changes you may desire. Thanks for taking the time. |
autoload/fugitive.vim
Outdated
if bufnr == bufnr('') && !exists('g:fugitive_event') | ||
let files = readfile(sentinel, '') | ||
call writefile([len(files)], sentinel) | ||
for file in reverse(files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this fair with each of 'splitbelow'
and 'nosplitbelow'
set? I would expect one to give an unintuitive order.
It's also a little weird that the buffer numbers would end up backwards. The first file would have the biggest buffer number.
(Perfection isn't mandatory here, given that we currently don't support multiple arguments at all.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
splitbelow
and nosplitbelow
behave as follows with reference to
currently focused window (see <W2>
in sketch below):
nosplitbelow
: stack grows upwards with first file in focus in top most
splitsplitbelow
: stack grows downwards with first file in focus in bottom
most split
With reversed sentinel file list iteration the command :G send-email --annotate HEAD~2
results in: (created splits are indicated by S
, numbers indicate
relative buffer number)
< > = focused window | W1 | |
|------| |
| W1 | | | <S2> | |
|------| | |------| |
| <W2> | W4 | -- nosplitbelow --> | S1 | W4 |
|------| | |------| |
| W3 | | | W2 | |
|------| |
| W3 | |
< > = focused window | W1 | |
|------| |
| W1 | | | W2 | |
|------| | |------| |
| <W2> | W4 | -- splitbelow --> | S1 | W4 |
|------| | |------| |
| W3 | | | <S2> | |
|------| |
| W3 | |
The last split is the focused one corresponding to the largest buffer number
holding the first file in the sentinel list. The first file in the sentinel
list corresponds to [PATCH 1/2]
which is the focused buffer (with the largest
buffer ID) in this case. Intuitively to me as a user, I would expect that start
editing the first patch and I would be less concerned about the actual buffer ID
relating to this file (while it may be confusing for scripting but I believe :G send-email
is mainly interactive). To me this would be the expected behavior.
Removing the file list reversal would result in the same sketch as above (w/r/t
to buffer IDs) but the active buffer <S2>
would hold the [PATCH 2/2]
. This
would be consistent w/r/t buffer ID <-->
file list in sentinel file, but
inconsistent with the file order you are presented when editing the patches
from the terminal with the command git send-email --annotate HEAD~2
(however,
for this case the buffer ID corresponds to the patch ID in the file as well).
I have pushed a commit for in-memory split buffer book-keeping relating to your
comment below (89ed871
). In this commit I have removed the reverse file
iteration but switch focus to the first created buffer instead. This is
consistent git send-mail
run from the command line and buffer ID <-->
patch
ID/sentinel file list. This results in:
< > = focused window | W1 | |
|------| |
| W1 | | | S2 | |
|------| | |------| |
| <W2> | W4 | -- nosplitbelow --> | <S1> | W4 |
|------| | |------| |
| W3 | | | W2 | |
|------| |
| W3 | |
< > = focused window | W1 | |
|------| |
| W1 | | | W2 | |
|------| | |------| |
| <W2> | W4 | -- splitbelow --> | <S1> | W4 |
|------| | |------| |
| W3 | | | S2 | |
|------| |
| W3 | |
With:
S1
: file0001
(a.k.a[PATCH 1/2]
)S2
: file0002
(a.k.a[PATCH 2/2]
)
autoload/fugitive.vim
Outdated
call feedkeys("\<C-\>\<C-N>:redraw!|call delete(" . string(sentinel) . | ||
\ ")|call fugitive#Resume()|checktime\r", 'n') | ||
else | ||
call writefile([active_buffers], sentinel) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably not a problem in practice, but it irks me a bit that this file can now contain either a list of files or a number. Can we do this in memory instead? Avoiding I/O is also a win in general.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I certainly agree with I/O argument. I have pushed a change that manages active buffers in memory via the state
dictionary (89ed871).
Git send-email by default uses multi-file edit mode (`sendemail.multiEdit`) when more than one patch file requires editing an associated email message and/or cover-letters. Multi edit mode spawns one editor instance with multiple files in argument list. This behavior is supported by creating multiple splits for a running vim instance when `:G send-email` is called. When the user sets `sendemail.multiEdit` to false in the local or global config, if multiple files need editing then they are processed sequentially in a single split at a time. Closes tpope#2352
Adds an additional 'active_buffers' dictionary to the state dictionary for tracking of possibly multiple buffers for the edit command. The 'active_buffers' dictionary has the buffer ID as key and associated file as value. The function s:RunEdit initializes the dictionary and s:RunBufDelete modifies its state.
28f17e5
to
89ed871
Compare
0b57d6f
to
2eaae3d
Compare
Added description for multifile edit behavior.
2eaae3d
to
9d5e351
Compare
Git send-email by default uses multi-file edit mode
(
sendemail.multiEdit
) when more than one patch file requires editing anassociated email message and/or cover-letters. Multi edit mode spawns
one editor instance with multiple files in argument list. This behavior
is supported by creating multiple splits for a running vim instance when
:G send-email
is called. When the user sets sendemail.multiEdit tofalse in the local or global config, if multiple files need editing then
they are processed sequentially in a single split at a time.
Closes #2352