Hi Bram,

2016-8-7(Sun) 22:19:48 UTC+9 Bram Moolenaar:
> Hirohito Higashi wrote:
> 
> > This is a proposal.
> > 
> > matchadd() and /\n can highlight end of line.
> > Currently, matchaddpos() can do this too.
> > 
> > I think, matchaddpos() should not do this.
> > Because this function specified position directory by user, it should be 
> > only to highlight certain parts of the *character*.
> > 
> > 
> > How to reproduce:
> > - Naked Vim with some options.
> >   $ vim -Nu NONE -i NONE -c "syntax on" -c "set hls" -c "call setline(1, 
> > '12345')"
> > - Highlight line:1,col:2 and line:1,col:6
> >   :echo matchaddpos('Error', [[1,2], [1,6]])
> > 
> > The behavior I want:
> > - Highlighted line:1,col:2, and not highlight line:1,col:6
> > 
> > Actual behavior:
> > - Highlighted both.
> > 
> > 
> > I wrote a patch with a test.
> > Please consider this proposal.
> 
> Hmm, I'm not sure.  As you mention, it will be different from other
> matches which do highlight the position just after the line.
> Why not leave out the position in the argument of matchaddpos()?

Around the text of the position that you specified in the matchaddpos() it can 
be changed.
Please check the last section of my patch.

+func Test_matchaddpos()
+  syntax on
+  set hlsearch
+
+  call setline(1, ['12345', 'NP'])
+  call matchaddpos('Error', [[1,2], [1,6], [2,2]])
+  redraw!
+  call assert_notequal(screenattr(2,2), 0)
+  call assert_equal(screenattr(2,2), screenattr(1,2))
+  call assert_notequal(screenattr(2,2), screenattr(1,6))
+  1
+  call matchadd('Search', 'N\|\n')
+  redraw!
+  call assert_notequal(screenattr(2,1), 0)
+  call assert_equal(screenattr(2,1), screenattr(1,6))
+  exec "norm! i0\<Esc>"
+  redraw!
+  call assert_equal(screenattr(2,2), screenattr(1,6))
+
+  nohl
+  syntax off
+  set hlsearch&
+endfunc

Position [1,6] of the highlight will change in the following operation.

  exec "norm! i0\<Esc>"

So, we should not leave out the position [1,6] in the argument of matchaddpos().
and need to change matchaddpos() behavior.

--
Best regards,
Hirohito Higashi (a.k.a. h_east)

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui