Giter Site home page Giter Site logo

Comments (6)

ggandor avatar ggandor commented on May 17, 2024 1

This is the one: d1084c0. It's about :DoMatchParen then. I will look into the source of matchparen again (help is still appreciated though).

from lightspeed.nvim.

TheBlob42 avatar TheBlob42 commented on May 17, 2024 1

I think I found the issue for what is happening.
See this line from the visual mode documentation (:h Visual):

If you use <Esc>, click the left mouse button or use any command that does a jump to another buffer
while in Visual mode, the highlighting stops and no text is affected.

When checking the source for the DoMatchParen command we can see that windo is used to activate the highlighting in all visible windows:

func s:DoMatchParen()
  runtime plugin/matchparen.vim
  let w = winnr()
  silent windo doau CursorMoved <-- this line here
  exe "noau ". w . "wincmd w"
endfunc

windo will navigate to every window of the current tabpage and execute the given command there (see :h windo). As soon as one of those windows is visiting another buffer than the current one the highlighting stops as stated in the visual mode documentation. That is the reason it works for splits showing the same buffer.

We could have a simple workaround to prevent this like the following:

(fn force-matchparen-highlight []
  ; NOTE: :DoMatchParen overwrites the current dot-repeat setting,
  ;       that should be (re)set after this call!
  (let [mode (vim.fn.mode)] ; save current mode
    (when (= (vim.fn.exists ":DoMatchParen") 2)
      (vim.cmd :DoMatchParen)
      (when (or (= mode "v") (= mode "V") (= mode "CTRL-V")) ; if last mode was "visual"
        (vim.cmd "normal gv")))))                            ; restore selection

from lightspeed.nvim.

ggandor avatar ggandor commented on May 17, 2024

Yep, I can reproduce, unfortunately. This is a pretty serious bug, and at the moment I have absolutely no idea what could cause this, and when will I have the time to hunt it down. (Thanks for raising this btw!)

from lightspeed.nvim.

ggandor avatar ggandor commented on May 17, 2024

Okay, the good news is that this bug is not present in the older commits, so it's binary-searchable at least. I'm kinda relieved :)

from lightspeed.nvim.

ggandor avatar ggandor commented on May 17, 2024

Wow, you're invaluable :) I think this might also be the reason why it breaks dot-repeat (the selection is gone).

On the other hand, have you actually tried the workaround? I tried reselecting with gv, but that did not work for me. The visual selection is not updated at that point, apparently, it restores the previous state. (Though I don't really understand why.)

But again, we can do something simpler: let's not use :DoMatchParen at all, but trigger the refresh manually then, with doautocmd CursorMoved, for our window only. This is a very clean solution.

from lightspeed.nvim.

TheBlob42 avatar TheBlob42 commented on May 17, 2024

No problem, I am always happy to help 🙂

For me it did work with gv, but never the less I like the solution using doautocmd CursorMoved way better. No need to "restart" matchparen for all open windows.

from lightspeed.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.