Skip to content
This repository has been archived by the owner on Aug 24, 2018. It is now read-only.

Issue with history transactions and autocomplete #51

Closed
alvaromartin opened this issue Nov 17, 2014 · 2 comments
Closed

Issue with history transactions and autocomplete #51

alvaromartin opened this issue Nov 17, 2014 · 2 comments
Labels

Comments

@alvaromartin
Copy link

I am having this issue when running autocomplete and vim-mode together. It autocompletes but also joins the next line and removes a few characters.

autocompletebug

Steps to reproduce:

  • make sure you have vim-mode installed
  • open autocomplete/spec/fixtures/sample.js
  • move to the end of the first line in insert mode
  • press enter
  • type "quick"
  • press ctrl-space.

The issue is happening because autocomplete is not committing the current transaction in AutocompleteView.attach so when it runs editor.abortTransaction in AutocompleteView.cancel, it aborts autocomplete's transaction + the previous vim-mode transaction.

A way to take care of this is to commit any existing transaction in AutocompleteView.attach:

  attach: ->
    @editor.commitTransaction() if @editor.getBuffer().history.isTransacting()
    @editor.beginTransaction()

This issue affects vim-mode and any package that could potentially have an unfinished transaction before AutocompleteView.attach is executed.

@maxbrunsfeld
Copy link
Contributor

Hi @alvaromartin,

Thanks for the excellent reproduction steps! We're aware of this issue and a fix is already on the way.

To fully resolve this issue, we had to move away from using open-ended transactions (::beginTransaction and ::commitTransaction), and to introduce a new feature in atom-core called 'checkpoints'. See atom/text-buffer#38, #53, and atom/vim-mode#448. The reason we can't simply apply your fix is that in vim-mode, each insert-mode session should constitute a single entry in the undo history. If the autocomplete view commits the transaction opened by vim-mode, multiple entries will be created in the undo history.

It may take some time for new versions of the packages to be released because they depend on the new checkpoint API, which is on master, but hasn't been released yet.

@maxbrunsfeld
Copy link
Contributor

Fixes are on master branches of autocomplete and vim-mode.

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

No branches or pull requests

2 participants