Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
vimagit
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GitHub Mirror
jreybert
vimagit
Commits
c2c3b874
Commit
c2c3b874
authored
Oct 20, 2015
by
Jerome Reybert
Browse files
Options
Downloads
Patches
Plain Diff
autoload/magit/sign.vim: rework some sign functions
parent
a3d362b0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
autoload/magit/sign.vim
+22
-10
22 additions, 10 deletions
autoload/magit/sign.vim
plugin/magit.vim
+1
-1
1 addition, 1 deletion
plugin/magit.vim
with
23 additions
and
11 deletions
autoload/magit/sign.vim
+
22
−
10
View file @
c2c3b874
...
@@ -19,11 +19,22 @@ let s:bufnr = bufnr(g:magit_buffer_name)
...
@@ -19,11 +19,22 @@ let s:bufnr = bufnr(g:magit_buffer_name)
function
!
magit#
sign
#remove_signs
(
sign_ids
)
function
!
magit#
sign
#remove_signs
(
sign_ids
)
let
bufnr
=
magit#utils#
bufnr
()
let
bufnr
=
magit#utils#
bufnr
()
for
sign
in
values
(
a:sign_ids
)
for
sign
in
values
(
a:sign_ids
)
echom
"sign unplace"
sign
.
id
execute
"sign unplace"
sign
.
id
execute
"sign unplace"
sign
.
id
endfor
endfor
endfunction
endfunction
function
!
magit#
sign
#add_sign
(
line
,
type
,
bufnr
)
let
id
=
<
SID
>
get_next_sign_id
()
execute
":sign place "
.
id
.
\
" line="
.
a:line
.
" name="
.
s:magit_mark_signs
[
a:type
]
.
\
" buffer="
.
a:bufnr
return
id
endfunction
function
!
magit#
sign
#remove_sign
(
id
)
execute
":sign unplace "
.
a:id
endfunction
" s:get_next_sign_id: helper function to increment sign ids
" s:get_next_sign_id: helper function to increment sign ids
function
!
s:get_next_sign_id
()
function
!
s:get_next_sign_id
()
let
next_id
=
s:next_sign_id
let
next_id
=
s:next_sign_id
...
@@ -65,31 +76,32 @@ endfunction
...
@@ -65,31 +76,32 @@ endfunction
" param[in] startline,endline: range of lines
" param[in] startline,endline: range of lines
" return Dict of marked lines
" return Dict of marked lines
function
!
magit#
sign
#find_stage_signs
(
startline
,
endline
)
function
!
magit#
sign
#find_stage_signs
(
startline
,
endline
)
return
magit#
sign
#find_signs
(
s:magit_mark_sign
,
a:startline
,
a:endline
)
return
magit#
sign
#find_signs
(
s:magit_mark_sign
s
.
M
,
a:startline
,
a:endline
)
endfunction
endfunction
" s:magit_mark_sign: string of the sign for lines to be staged
" s:magit_mark_sign: string of the sign for lines to be staged
let
s:magit_mark_sign
=
'MagitMark'
let
s:magit_mark_sign
s
=
{
'M'
:
'MagitTBS'
,
'S'
:
'MagitBS'
,
'E'
:
'MagitBE'
}
" magit#sign#init: initializer function for signs
" magit#sign#init: initializer function for signs
function
!
magit#
sign
#init
()
function
!
magit#
sign
#init
()
execute
"sign define "
.
s:magit_mark_sign
.
" text=S> linehl=Visual"
execute
"sign define "
.
s:magit_mark_signs
.
M
.
" text=S> linehl=Visual"
execute
"sign define "
.
s:magit_mark_signs
.
S
execute
"sign define "
.
s:magit_mark_signs
.
E
endfunction
endfunction
" magit#sign#toggle_signs: toggle marks for range of lines
" magit#sign#toggle_signs: toggle marks for range of lines
" marked lines are unmarked, non marked are marked
" marked lines are unmarked, non marked are marked
" param[in] type; type of sign to toggle (see s:magit_mark_signs)
" param[in] startline,endline: range of lines
" param[in] startline,endline: range of lines
function
!
magit#
sign
#toggle_signs
(
startline
,
endline
)
function
!
magit#
sign
#toggle_signs
(
type
,
startline
,
endline
)
let
bufnr
=
magit#utils#
bufnr
()
let
bufnr
=
magit#utils#
bufnr
()
let
current_signs
=
magit#
sign
#find_signs
(
s:magit_mark_sign
,
a:startline
,
a:endline
)
let
current_signs
=
magit#
sign
#find_signs
(
s:magit_mark_sign
s
[
a:type
]
,
a:startline
,
a:endline
)
let
line
=
a:startline
let
line
=
a:startline
while
(
line
<=
a:endline
)
while
(
line
<=
a:endline
)
if
(
has_key
(
current_signs
,
line
)
==
0
)
if
(
has_key
(
current_signs
,
line
)
==
0
)
execute
":sign place "
.
<
SID
>
get_next_sign_id
()
.
call
magit#
sign
#add_sign
(
line
,
a:type
,
bufnr
)
\
" line="
.
line
.
" name="
.
s:magit_mark_sign
.
\
" buffer="
.
bufnr
else
else
execute
":sign unplace "
.
current_signs
[
line
].
id
call
magit#
sign
#remove_sign
(
current_signs
[
line
].
id
)
endif
endif
let
line
+=
1
let
line
+=
1
endwhile
endwhile
...
...
This diff is collapsed.
Click to expand it.
plugin/magit.vim
+
1
−
1
View file @
c2c3b874
...
@@ -489,7 +489,7 @@ function! s:mg_mark_lines_in_hunk(start_select_line, end_select_line)
...
@@ -489,7 +489,7 @@ function! s:mg_mark_lines_in_hunk(start_select_line, end_select_line)
if
(
a:start_select_line
<
starthunk
||
a:end_select_line
>
endhunk
)
if
(
a:start_select_line
<
starthunk
||
a:end_select_line
>
endhunk
)
throw
'out of hunk selection'
throw
'out of hunk selection'
endif
endif
return
magit#
sign
#toggle_signs
(
a:start_select_line
,
a:end_select_line
)
return
magit#
sign
#toggle_signs
(
'M'
,
a:start_select_line
,
a:end_select_line
)
endfunction
endfunction
" s:mg_get_section: helper function to get the current section, according to
" s:mg_get_section: helper function to get the current section, according to
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment