Skip to content

Line Wrap + Code Fold support #34

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

Closed
wants to merge 12 commits into from
Closed

Conversation

alexcorre
Copy link
Owner

This pull request adds support code folding and Fixes #3.

Add support for:

  • Code folding
  • Soft line wraps

@alexcorre
Copy link
Owner Author

Here is the start on #3 fix @dmnd. feedback is welcome on this WIP

@alexcorre
Copy link
Owner Author

Thanks I'll make these fixes...def want to be working the React / coffeescript idioms. Knew this first version didn't quite fit the way it should

@alexcorre
Copy link
Owner Author

Hey @dmnd i have refactored to use forceUpdate(). This causes the BlameListView render to be called and the annotations to be properly prepared to handle folds, but it does not cause the BlameLinesComponent to be redrawn. Any ideas on why? I haven't been able to figure it out.

@dmnd
Copy link
Contributor

dmnd commented Sep 8, 2014

It's probably because of shouldComponentUpdate. Two options:

  1. Add a check to see if annotations have changed:

    shouldComponentUpdate: ({loading, dirty, annotations}) ->
      if @props.loading and not loading and not @props.dirty
        # finished the initial load
        return true
    
      if @props.dirty and not dirty
        # user hit save, so re-render according to edits
        return true
    
      unless _.isEqual @props.annotations, annotations
        # the annotations array changes when code is folded
        # TODO: use an immutable array so we can do an identity check here
        return true
    
      # in all other cases, don't bother re-rendering
      # TODO: is this still a useful optimization?
      return false

    This check is pretty expensive now since we have to do a deep comparison. In theory we could just do an identity comparison as long as we're careful to never mutate that array in place. That might be ok? If we change to using an immutable array, that can be enforced.

  2. Just delete shouldComponentUpdate. I originally added this when we had no reason to re-render the view. In theory it helps performance, but I never actually verified that. When we had no reason to re-render it made sense to have it just to make things easy to reason about. But that time seems to have passed now 😄 You can probably just delete this function and let the view always re-render when its parent does.

@alexcorre alexcorre closed this May 29, 2015
@alexcorre
Copy link
Owner Author

closing this. looking into bigger changes to how the front end rendering works.

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.

blame doesnt show correct lines when code is folded or lines are wrapped
2 participants