Skip to content
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

リージョンハイライトで、数字がハイライトされない。 #6

Closed
t9md opened this issue Dec 12, 2013 · 4 comments
Closed

Comments

@t9md
Copy link
Contributor

t9md commented Dec 12, 2013

一応別Issueとして立てます。

10

のような'数字のみ'の貼付け時にハイライトされない。
<C-v> とかで 数字選択した場合にはハイライトされる。
つまり、<C-v> 以外のハイライトパターンがマッチしてない。

元々僕のハイライトが適当だったのでこうなってる。
以下だと、ちゃんとハイライトされました。
確認して問題なければ対応ねがいます。

function! s:_rounder._region_hl(regtype) "{{{
  let [sl, sc] = [line("'["), col("'[")]
  let [el, ec] = [line("']"), col("']")]
  let pat =
        \ a:regtype[0] ==# "\<C-v>" ? printf('\v\c%%>%dl%%>%dc.*%%<%dl%%<%dc', sl-1, sc-1, el+1, ec+1) :
        \ a:regtype[0] ==# 'v' ? printf('\v\c%%%dl%%>%dc\_.*%%%dl%%<%dc', sl, sc-1, el, ec+1) :
        \ printf('\v\c%%%dl\_.*%%%dl', sl, el)
  if self.match_id
    try| call matchdelete(self.match_id)| catch /E803/| endtry
    call matchadd(g:yankround_region_hl_groupname, pat, '', self.match_id)
  else
    let self.match_id = matchadd(g:yankround_region_hl_groupname, pat)
    let s:_rounder.match_id = self.match_id
  end
endfunction
@t9md
Copy link
Contributor Author

t9md commented Dec 12, 2013

あ、あと just info ですが、 matchadd() に matchid を指定するのは、リクエストしたIDが無理だと、失敗するので、私は使わないようにしてます。他のプラグインでその値とってたら、使えない。

@LeafCage
Copy link
Owner

修正されました。

ちなみに、matchidはウィンドウローカルな値でしたね。
matchidがグローバルな値でしたなら私の実装で同じIDの使い回しが出来たのでしょうけれど、ウィンドウローカルなので、保持していても別のウィンドウに移れば保持したIDは全く意味をなさないのでした。

保持するようにしていた理由は、一度そのウィンドウで使われたID値はたとえ削除されていてもaddmatch()は新しい別のIDを振り出すので、ID値が増えていくのが気持ち悪く感じたのと、もし不具合でIDの削除し損じが生じた場合のIDの特定が容易だということからでした。

ウィンドウローカル変数に保持する案もあるのですが、とりあえずIDは使い捨てという実装を取りました。

@t9md
Copy link
Contributor Author

t9md commented Dec 12, 2013

対応ありがとうございます。
問題正しく理解してるかわかりませんが
私のquickhlでは
https://github.com/t9md/vim-quickhl/blob/master/autoload/quickhl.vim#L24

のようにwindow移動時にidかき集めてます。

@LeafCage
Copy link
Owner

この問題の正確な表現は、2文字以下の文字列にはリージョンハイライトがされないというものでした。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants