Skip to content

Conversation

@GustavoMF31
Copy link

The refactors were:

  • Move writing and updating the file being edited to s:IdrisCommand (removes a lot of code duplication)
  • Move saving the window view to IWrite (this guarantees that the window always returns to it's previous position. The reload command used to save just the cursor position, not the whole window view, and that caused annoyances)

A change made that isn't really a refactor is that now undo still works after issuing a command that updates the idris-response buffer. Previously, the process of writing to it made the buffer with the current file be temporarily abandoned, causing the undo history to be lost. The fix is implemented by temporarily overwriting the hidden option, making it become a hidden buffer, rather than abandoned. There might be a more straightforward way of implementing this though, suggestions are welcomed.

The implementation of TypeAt is rather simple. I'm not sure about which key would be the best for it though. My initial idea was <LocalLeader>ta, TypeAt's initials, but that would make Vim wait for a second keypress before issuing a regular <LocalLeader>t, which is rather inconvenient. I settled on <LocalLeader>y for lack of anything better.

I'm sorry if I ended up coupling too many unrelated changes into this pull request, i'm kind of still learning how to help with open source. If any changes are necessary just let me know and I'll do my best.

The previous behavior was to just save the cursor position. That worked
fine in most cases, but caused the window to scroll back up when it was
scrolled more than the height of the text. Info about winsaveview is
available on ':help winsaveview()'. The undo history is kept by
temporarily turning on the 'hidden' option. That prevents the code
buffer from being abandoned when the buffer switch is made.
Having these as part of the responsibilities of each command led to
them being duplicated in most commands. This does mean that commands
that previously didn't need to write the file now will.
Turns out the :e command also moves the cursor and repositions the
window. To prevent this, the window view is saved before the :e and
restored afterwards.
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

Successfully merging this pull request may close these issues.

1 participant