-
Notifications
You must be signed in to change notification settings - Fork 49
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
Fix 149, commit append to the last line #150
Fix 149, commit append to the last line #150
Conversation
Just to let you know, I watched your PR the first day, but I did not found time to test it. Seems quite good to me. I just wonder the Thanks for the PR anyway! |
02451a5
to
dc18c49
Compare
Thank you for reviewing. |
End of file vim pattern is |
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.
you spotted the right codelines to fix the bug, but the fix is wrong.
The usage of line()
makes no sense here, you don't want to check against the content of the last line (which is certainly empty line
), because you could have empty line in your commit message. Instead, use the pattern \%$
, which is regex pattern for end of file.
Others comments are mainly cosmetics, but I would appreciate them too.
plugin/magit.vim
Outdated
@@ -293,7 +293,13 @@ endfunction | |||
function! s:mg_get_commit_msg(...) | |||
let commit_section_pat_start='^'.g:magit_sections.commit.'$' | |||
" Get next section pattern with g:magit_default_sections order | |||
let commit_section_pat_end='^'.g:magit_sections[g:magit_default_sections[match(g:magit_default_sections, 'commit')+1]].'$' | |||
if ( match(g:magit_default_sections, 'commit')+1 >= len(g:magit_default_sections) ) |
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.
use intermediate variable to store match(g:magit_default_sections, 'commit')
result
check if this position is equal to len + 1
plugin/magit.vim
Outdated
@@ -293,7 +293,13 @@ endfunction | |||
function! s:mg_get_commit_msg(...) | |||
let commit_section_pat_start='^'.g:magit_sections.commit.'$' | |||
" Get next section pattern with g:magit_default_sections order | |||
let commit_section_pat_end='^'.g:magit_sections[g:magit_default_sections[match(g:magit_default_sections, 'commit')+1]].'$' | |||
if ( match(g:magit_default_sections, 'commit')+1 >= len(g:magit_default_sections) ) | |||
let commit_position = line("$EOF") |
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.
do not use intermediate variable for this, store directly in commit_section_pat_end
use \%$
pattern, without line()
plugin/magit.vim
Outdated
if ( match(g:magit_default_sections, 'commit')+1 >= len(g:magit_default_sections) ) | ||
let commit_position = line("$EOF") | ||
else | ||
let commit_position = g:magit_sections[g:magit_default_sections[match(g:magit_default_sections, 'commit')+1]] |
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.
use intermediate variable declared before
keep ^
and $
here
dc18c49
to
3c06923
Compare
@jreybert sorry, i am not good at writing vimscript. |
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.
Excellent! Just one last thing and you're good.
plugin/magit.vim
Outdated
if ( commit_position + 1 == len(g:magit_default_sections) ) | ||
let commit_section_pat_end='\%$' | ||
else | ||
let commit_section_pat_end='^'.g:magit_sections[g:magit_default_sections[match(g:magit_default_sections, 'commit')+1]].'$' |
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.
Reuse commit_position
here.
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 fixed!
3c06923
to
9e3d348
Compare
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.
Perfect.
I am sorry, two last things I did not noticed the first time:
- remove the file
.development.vim
from your commit - rename the commit title to something like: "Handle commit set at the end of magit_default_sections", and add "ref An error occurs when commit set at the end of magit_default_sections #149" (the sign # is important) in the commit body.
9e3d348
to
76350ab
Compare
oops! sorry, i deleted |
Excellent, thanks for the PR and for all your changes through the review process! |
Thanks for the merge! |
ref. #149
When set commit at the end of default section, append to the last line.