Code Monkey home page Code Monkey logo

Comments (6)

pseewald avatar pseewald commented on May 16, 2024

I can not reproduce this, can you be more specific in what situation this happens (what is the action you undo?). I can not see how the index can be out of range, since this line where the error happens is only executed if the total number of lines has not changed (anyfold_ind_actual is a list of size number of lines).

from vim-anyfold.

sunaku avatar sunaku commented on May 16, 2024

Sorry about the lack of instructions to reproduce the issue. 😰 Try this:

  1. Start Vim.
  2. Run :setfiletype mail
  3. Insert the word "hello" by typing ihello<ESC>
  4. Open a new line and insert "world" by typing oworld<ESC>
  5. Trigger the undo mechanism by typing u
  6. Observe the error message.

from vim-anyfold.

pseewald avatar pseewald commented on May 16, 2024

Thanks! But I don't get an error message. In fact, when I undo, the line that triggers the error message is not even executed (it should not be executed if the number of lines has changed).

Could you try the following to narrow down the bug:

in autoload/anyfold.vim of the vim-anyfold directory, put a statement that prints delta_lines, this is the number of lines that have been added / removed:

diff --git a/autoload/anyfold.vim b/autoload/anyfold.vim
index e293498..a5bac91 100644
--- a/autoload/anyfold.vim
+++ b/autoload/anyfold.vim
@@ -369,6 +369,7 @@ function! s:ReloadFolds(lnum) abort

     let delta_lines = line('$') - len(b:anyfold_ind_actual)

+    echom delta_lines
     if delta_lines == 0
         let indents_same = 1
         let curr_line = changed[0]

Then run the example you specified above. Afterwards get the printed numbers by running :messages. What numbers do you see (ignoring all messages that are not a number)? I get 0, 1, -1, as expected.

from vim-anyfold.

pseewald avatar pseewald commented on May 16, 2024

I could reproduce the issue with a similar example:

  1. Start Vim
  2. type ihello<ESC>
  3. yank and paste hello to end of line by typing yiw$p
  4. Trigger the undo mechanism by typing u

This must be a bug of vim: when you now try to jump to last changed character using '], you get the error message
E19: Mark has invalid line number

vim-anyfold is relying on '[ & '] to get the first and last line of the changed text.

I'll implement a workaround that checks that '] does not exceed the last line.

from vim-anyfold.

pseewald avatar pseewald commented on May 16, 2024

I committed a workaround that solves this problem for vim-anyfold and I filed an issue vim/vim#1281.

from vim-anyfold.

sunaku avatar sunaku commented on May 16, 2024

from vim-anyfold.

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.