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

breaks undo #2

Closed
justinmk opened this issue Nov 8, 2014 · 18 comments
Closed

breaks undo #2

justinmk opened this issue Nov 8, 2014 · 18 comments

Comments

@justinmk
Copy link

justinmk commented Nov 8, 2014

This looks like a promising plugin. I would like to make you aware of Raimondi/delimitMate#138 which has discussion about fixing undo/redo with these types of plugins. I just tried lexima.vim, and although dot-repeat seems to work, it still breaks undo.

The key to solving undo/redo is in this comment: Raimondi/delimitMate#138 (comment)

There is an edge case with visual-block mode: Raimondi/delimitMate#138 (comment)

But fixing undo is vastly more important in my opinion. No one has taken the time to implement the solution yet, though.

@cohama
Copy link
Owner

cohama commented Nov 9, 2014

Thanks for information.
I'll try to fix this.

@cohama
Copy link
Owner

cohama commented Nov 12, 2014

undo is fixed by that but it is no longer dot-repeatable because of existence of <Esc>.
Since this plugin's concept is "dot-repeatable", your solution is not acceptable.

@blueyed
Copy link
Contributor

blueyed commented Nov 27, 2014

Regarding the issue in delimitMate:

@justinmk
I had started with a PR, which is only missing the repeat support IIRC: https://github.com/Raimondi/delimitMate/pull/184/files

The idea would be to use @tpope's vim-repeat, but I have not figured out how it should be used in the context of delimitMate (Raimondi/delimitMate#138 (comment)).

@cohama
Copy link
Owner

cohama commented Nov 27, 2014

tpope's vim-repeat cannot be used for this sort of plugins.
The concept of vim-repeat is recording your key sequence. If you type ciwfoo<Esc>, repeat#set("ciwfoo\<Esc>") should be called. But how can I recognize that you have typed ciw?
It was very difficult for me.

@dai-shi
Copy link

dai-shi commented Feb 13, 2015

Hi, I'm not familiar with this issue, but is this related?
http://code.google.com/p/vim/issues/detail?id=202

@justinmk
Copy link
Author

@dai-shi no

@chrisbra
Copy link

chrisbra commented Dec 1, 2015

Note: Starting from version 7.4.849 you can use <C-G>Cursor to move within a line and not break undo/redo

@cohama
Copy link
Owner

cohama commented Dec 3, 2015

Thanks. You mean <C-G>U?
I have already know that and I will try to implement in a future version.

@ghost
Copy link

ghost commented Dec 26, 2016

Any updates on this? Is there perhaps a workaround I could use?

@nhooyr
Copy link

nhooyr commented Feb 4, 2017

Checkout Raimondi/delimitMate#227

@kutsan
Copy link

kutsan commented Apr 14, 2018

It's been nearly four years since the issue created. It was a promising plugin among other ones, so bad I can't use it because of this problem.

Friendly ping @cohama.

@mattn
Copy link

mattn commented Aug 29, 2019

A cause of breaking undo is calling setline while inserting via \<C-r>=.

@cohama
Copy link
Owner

cohama commented Aug 29, 2019

I'm sure that.

In historically reason, lexima uses setline to achieve dot-repeat feature and my implementation heavily depends on it.

Sorry for slow response and I will try re-implementation for this issue on this week.
@kutsan

@cohama
Copy link
Owner

cohama commented Jul 1, 2020

No, sorry. This problem is very difficult for now.

@ghost
Copy link

ghost commented Jul 1, 2020

@cohama Thanks for the update! And no worries, your plugin is very much appreciated!

If it helps anyone, I have switched to a simple solution that is not quite as good as this plugin but works okayish:

" Complete braces on <CR> in a sensible way
function! s:complete_braces()
  let line = getline('.')
  let col = col('.')
  if col < 1000 && col == len(line) + 1 && matchstr(line, '\%' . (col-1) . 'c.') == '{'
    return "}\<C-o>k\<C-o>A\<CR>"
  endif
  return ""
endfunction
inoremap <buffer><expr><CR> "\<CR>" . <SID>complete_braces()

It shouldn't be too hard to extend this manually for slightly more complicated cases...

@cohama
Copy link
Owner

cohama commented Jan 6, 2022

Hi everyone. I have updated lexima.vim and partially fix this problem.

lexima.vim does not break undo until <CR> input.

hoo(bar(ok)) can be done undo in one step.

However, in multiline input like bellow

foo{
  |
}

undo is still broken (<CR> splits undo).

@uplus
Copy link
Contributor

uplus commented Jan 19, 2022

This is a great fix 🎉

doronbehar pushed a commit to doronbehar/lexima.vim that referenced this issue Apr 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants