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

Buffer refactor #535

Open
wants to merge 44 commits into
base: develop
Choose a base branch
from

Commits on Nov 18, 2013

  1. Make XVimBuffer a reality

    This object will now be the main entry point to manipulate the content of
    the textStorage, so that we don't have to extend the NSTextStorage with
    categories.
    
    XVimBuffer is now created each time we learn about a new Document that
    responds to -textStorage which XCode documents do.
    
    XVimBuffer also knows about the undo manager, and is used to be the target
    of the specific vim action we mean to undo, which means that undoing the
    cursor positions won't crash anymore (Layout managers and textviews come
    and go, and it's not correct to make them the target of an undo
    operation).
    JohnTheAppleSeed committed Nov 18, 2013
    Configuration menu
    Copy the full SHA
    552460a View commit details
    Browse the repository at this point in the history
  2. Migrate most of XVimTextStoring to XVimBuffer

    XVimTextStoring becomes a protocol that you implement when you intend to
    give better alternatives than the default implementations from XVimBuffer.
    
    This commit doesn't alter code, it merely moves some around, and adpt
    callers.
    JohnTheAppleSeed committed Nov 18, 2013
    Configuration menu
    Copy the full SHA
    04a77f2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    0211582 View commit details
    Browse the repository at this point in the history

Commits on Nov 19, 2013

  1. Rework undo to take complete ownership of some operations

    This makes editing the text-storage faster than going through the view
    obviously.
    
    Use this as a proof of concept to reimplement the bulk of xvim_shift
    as -[XVimBuffer shiftLines:column:count:right:block:]
    
    The performance that this code reaches now is bluffing compared to the
    previous one. It's still not nearly as fast as vim, but it's decent.
    
    Note that the cursor position handling code is still messy, which makes
    the number of parameters to that selector properly disgusting, but we're
    getting there.
    JohnTheAppleSeed committed Nov 19, 2013
    Configuration menu
    Copy the full SHA
    e3bcb62 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    694d02e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    01d9100 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    b9709a6 View commit details
    Browse the repository at this point in the history
  5. Get rid of the lastVisual* properties on the XVim instance

    Move them to a proper ivar of the XVimBuffer instead
    This is the beginning of moving a lot of stuff there, so that we can
    capture the buffer state on undo/redo properly.
    JohnTheAppleSeed committed Nov 19, 2013
    Configuration menu
    Copy the full SHA
    1715526 View commit details
    Browse the repository at this point in the history

Commits on Nov 20, 2013

  1. Reimplement paragraph moves using XVimBuffer clean methods

    As a side effect, this means we now support CRLF properly for this
    command, which should help for XVimProject#530
    
    Fix a couple of issues in the XVimBuffer methods that this new code
    spotted.
    JohnTheAppleSeed committed Nov 20, 2013
    Configuration menu
    Copy the full SHA
    030a795 View commit details
    Browse the repository at this point in the history

Commits on Nov 21, 2013

  1. Dead code

    JohnTheAppleSeed committed Nov 21, 2013
    Configuration menu
    Copy the full SHA
    eebc66a View commit details
    Browse the repository at this point in the history
  2. fix Off-by-one

    JohnTheAppleSeed committed Nov 21, 2013
    Configuration menu
    Copy the full SHA
    98bb868 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a776bfd View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4917b21 View commit details
    Browse the repository at this point in the history
  5. Add an NSObject(XVimAdditions) category for swizzling

    Hooker is really a disgusting hack which uses Hook classes for no good
    purposes and does no compile time check.
    
    Let's use this to modify the behavior of (typically) NSTextView and
    NSTextStorage if they have xvim_* objects associated with them.
    JohnTheAppleSeed committed Nov 21, 2013
    Configuration menu
    Copy the full SHA
    51f6b2d View commit details
    Browse the repository at this point in the history
  6. Have an XVimView much like we have an XVimBuffer

    +[XVimView initialize] swizzles NSTextView like we used to do on the DVT
    one. Nothing was really DVT speciic in the DVTSourceTextViewHook in the
    first place. The swizzling does nothing if there is no XVimView associated
    with the NSTextView, or if XVim is disabled.  All that is non specific to
    XCode.
    
    Rewrite IDEEditorHook as an IDEEditor+XVim category with swizzling.
    In the -didSetupEditor override, detect when there are
    DVTSourceTextView's that are the one we know what to do with.
    
    Check their document has a file:// URL (so that the script editor in the
    Xcode rules are ignored). If the textStorage happens to already be
    created, allocate the XVimBuffer right away.
    
    In theory we would have to check when the document for a given TextView
    changes whether we still support XVim, but XCode actually destroys and
    recreates the view each time you switch documents, so it doesn't matter.
    JohnTheAppleSeed committed Nov 21, 2013
    Configuration menu
    Copy the full SHA
    09bc132 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    f93d3a6 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    b7b911c View commit details
    Browse the repository at this point in the history
  9. Move the IDEWorkspaceWindowHook as a swizzle in XVimHookManager

    It's disabled by default because it only make sense for debugging
    purposes.
    JohnTheAppleSeed committed Nov 21, 2013
    Configuration menu
    Copy the full SHA
    3afd25b View commit details
    Browse the repository at this point in the history

Commits on Nov 22, 2013

  1. wibble

    JohnTheAppleSeed committed Nov 22, 2013
    Configuration menu
    Copy the full SHA
    e73d9d5 View commit details
    Browse the repository at this point in the history
  2. Get rid of Hooker, move DVTSourceTextScrollView to a swizzling class too

    And fix a silly bug with the swizzling category when the class doesn't
    override the selector we're swizzling.
    JohnTheAppleSeed committed Nov 22, 2013
    Configuration menu
    Copy the full SHA
    e234ef0 View commit details
    Browse the repository at this point in the history
  3. Get rid of XVimTextViewProtocol

    it's replaced by XVimView/XVimBuffer.
    It's a nice reference of the things to have though.
    JohnTheAppleSeed committed Nov 22, 2013
    Configuration menu
    Copy the full SHA
    559770f View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    c068d4a View commit details
    Browse the repository at this point in the history
  5. Make the XCode project happier

    Do not hardcode XCode path to /Applications/Xcode 2.app, and find the
    framework relative the $DEVELOPER_DIR, which will do what's right.
    
    Upgrade warnings for XCode 5
    JohnTheAppleSeed committed Nov 22, 2013
    Configuration menu
    Copy the full SHA
    c55fcb6 View commit details
    Browse the repository at this point in the history
  6. To help debugging: log exceptions to the console right away

    It's been a huge help for development for me.
    JohnTheAppleSeed committed Nov 22, 2013
    Configuration menu
    Copy the full SHA
    ea25af4 View commit details
    Browse the repository at this point in the history
  7. Refactor character swaps operators into XVimBuffer

    Fold the Tilde/Lower/Upper (and Rot13) into a single SwapChar evaluator.
    Fix various repeat issues with those.
    
    Use it in the normal, visual, GAction and GVisual evaluators as required.
    
    This obviously uses the new undo architecture, hence should be faster
    JohnTheAppleSeed committed Nov 22, 2013
    Configuration menu
    Copy the full SHA
    7533e08 View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    598f882 View commit details
    Browse the repository at this point in the history

Commits on Nov 24, 2013

  1. Refactor NSTextView(VimOperation) into the XVimView

    This is a huge refactor that makes the code more independant, more
    efficient, and acting on XVimView's and XVimBuffer's as much as possible.
    
    In particular, this commit tries not to use any NSTextView methods to
    modify the content, which has several important side effects:
    - it's more efficient, since we don't go through all the XCode logic to
      handle edits (it's really a waste when we're doing block operationst
      typically), performance for several operations is visibly faster than it
      used to be;
    - it's better for the user as this goes below XCode AutoCompletion code,
      and doesn't pop up spurious dialogs when you're in command mode anymore;
    - this goes through our Undo logic which allows exact coalescing and
      cursor placement, instead of relying on the Appkit doing the right thing
      before. (and it doesn't for insertion, but we'll get to that at some
      point).
    
    This commit also does tons of cleanups with the selection and movement,
    notably fixing behavior when MOTION_END_OF_LINE ($) is used, as this
    should be preserved, and wasn't
    
    Note that for now XVimView is still XCode dependant, because I didn't
    write a category to swizzle XCode classes, and didn't write a protocol
    for the TextView yet. Such a protocol will include anything that is
    rendering related, like placeholder handling. Indenting should go to the
    NSTextStorage instead, as it's strictly content related.
    
    I wouldn't be surprised there are a couple of regression, crashers, but
    the test-suite passes, and I'm living on that patch now.
    JohnTheAppleSeed committed Nov 24, 2013
    Configuration menu
    Copy the full SHA
    50b42ef View commit details
    Browse the repository at this point in the history
  2. Force synthesizing properties

    I had a bug because it's not on by default in XVim and a property was
    automatically synthesized because I didn't implement the selector and had
    no warning.
    JohnTheAppleSeed committed Nov 24, 2013
    Configuration menu
    Copy the full SHA
    55acaf3 View commit details
    Browse the repository at this point in the history

Commits on Nov 25, 2013

  1. Hunt of DVTKIT: Move -_indentCharacterRange into XVimTextStoring

    And implement all the forwarders all the way down.
    JohnTheAppleSeed committed Nov 25, 2013
    Configuration menu
    Copy the full SHA
    f49d75d View commit details
    Browse the repository at this point in the history
  2. Begin to remove some things from the NSTextStorage category.

    Hide some -is* from the NSTextStorage category, move isLastLine as
    isIndexOnLastLine on XVimBuffer.
    JohnTheAppleSeed committed Nov 25, 2013
    Configuration menu
    Copy the full SHA
    45b5e26 View commit details
    Browse the repository at this point in the history
  3. Fix b_v_D

    btw it's not 100% correct because gv doesn't quite do the right thing yet.
    JohnTheAppleSeed committed Nov 25, 2013
    Configuration menu
    Copy the full SHA
    0f824b8 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    890f5ad View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    7e2d1c8 View commit details
    Browse the repository at this point in the history
  6. Move some more functions from the NSTextStorage category to XVimBuffer

    Those functions are related to position of the index within the line.
    JohnTheAppleSeed committed Nov 25, 2013
    Configuration menu
    Copy the full SHA
    0c2519e View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    4fa859c View commit details
    Browse the repository at this point in the history

Commits on Nov 26, 2013

  1. Refactor -{prev,next}{,Line}:... in XVimBuffer

    This is now:
        -indexOfCharMotion:index:options:
        -indexOfLineMotion:index:column:
    
    Implement _/+/-/$/CR/C_m/... using this.
    
    Also rename and properly namespace MOTION_OPTION as XVimMotionOptions and
    the MOPT_ prefix.
    JohnTheAppleSeed committed Nov 26, 2013
    Configuration menu
    Copy the full SHA
    a659427 View commit details
    Browse the repository at this point in the history
  2. Fix a few mistakes, and support movement |

    When normal-mode replace failed, it used to fail to quit insert mode,
    which broke several motions. Make -escapeFromInsert take a boolean to know
    whether in addition to quitting INSERT mode, we should also go backwards.
    
    Replace also had an off-by-one that prevented to replace the Last char of
    the line (a >= comparison really should be >).
    
    Add a BAR selector to the XVimMotionEvaluator, and a new
    MOTION_COLUMN_OF_LINE enum value.
    JohnTheAppleSeed committed Nov 26, 2013
    Configuration menu
    Copy the full SHA
    4d73d39 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    794f94d View commit details
    Browse the repository at this point in the history
  4. Fixup position after undo

    The reason for that is that when undo is generated by XCode it can leave
    us in really awkward places.
    
    Example, go to the end of a line, type:
    
    C<ESC>
    i.<ESC>
    u
    <-- at this point, your cursor is on the end-of-line where it shouldn't be
    since we're in normal mode.
    
    When the undo are generated by us, this of course never happens (or would
    be a bug).
    JohnTheAppleSeed committed Nov 26, 2013
    Configuration menu
    Copy the full SHA
    ec162f0 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    832005e View commit details
    Browse the repository at this point in the history

Commits on Nov 27, 2013

  1. Do not use straight @"\n" in the code

    Use the line endings we guess from the first line of the file.
    This, really fixes dd for me on CRLF files now.
    
    It also means we support Classic Mac line endings too (CR-ended lines)
    
    Also compute the end-of-line to eat when deleting/yanking at the end
    properly.
    
    This should make things better for XVimProject#530
    JohnTheAppleSeed committed Nov 27, 2013
    Configuration menu
    Copy the full SHA
    6528a7c View commit details
    Browse the repository at this point in the history
  2. Add some comments

    JohnTheAppleSeed committed Nov 27, 2013
    Configuration menu
    Copy the full SHA
    934c8a2 View commit details
    Browse the repository at this point in the history

Commits on Dec 1, 2013

  1. Improve performance and correctness of the event handling code

    Reduce the number of calls on each keystroke by avoiding the
    -selectorForInstance + instanceResponds + ... calls
    
    Avoid using NSStrings to compute the selector, it does malloc()s, a simple
    buffer + sel_getUid() is faster
    
    Use the NS*FunctionKey values from Foundation instead of hardcoded values.
    And now my XVim stops assert()ing when I use F13 by mistake.
    
    Avoid using self.{modifier,character} but access the ivars directly, it's
    faster.
    
    Use iswprint() instead of isPrintable, it's supposed to do what's right...
    JohnTheAppleSeed committed Dec 1, 2013
    Configuration menu
    Copy the full SHA
    38e71db View commit details
    Browse the repository at this point in the history
  2. Do not swizzle KV Observing and -dealloc on NSTextView

    both sound like a very bad idea, move that stuff to the XVimView where it
    belongs. The less we swizzle, the better we are.
    JohnTheAppleSeed committed Dec 1, 2013
    Configuration menu
    Copy the full SHA
    e11416a View commit details
    Browse the repository at this point in the history