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

Allows expanding the visible lines of code (Fixes #370) #409

Closed

Conversation

zedtux
Copy link

@zedtux zedtux commented Nov 15, 2017

This PR implements the "Expand" icons like in Github (see #370). Clicking an expander calls the backend which returns only the code to be updated in the .code div so that the reste of the page stays as it is (no reset of the REPL).

Here is a preview:

screen shot 2017-11-16 at 10 05 18

After having clicked the top expander:

screen shot 2017-11-16 at 10 05 56

@zedtux zedtux force-pushed the feature/adds-expands-to-code-view branch 4 times, most recently from 7bd067e to 6553899 Compare November 16, 2017 09:14
@zedtux
Copy link
Author

zedtux commented Nov 20, 2017

@charliesome can I draw your attention to this PR?

Copy link
Member

@RobinDaugherty RobinDaugherty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the CodeFormatter class is the correct place to render HTML containing user interface elements. Why not render these in main.erb?

%{<div class="code_linenums">#{formatted_nums.join}</div><div class="code">#{super}</div>}
code = ''

if true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this condition here? It seems like this should be deciding whether there are more lines available.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@RobinDaugherty sorry about that ... it is something I forget to finish, I'm updating it now.

code << "<div class='code_linenums'>#{formatted_nums.join}</div>"
code << "<div class='code'>#{super}</div>"

if true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for this condition.

@@ -19,8 +19,40 @@ def formatted_nums
}
end

def expander_icon
'<svg aria-hidden="true" class="octicon octicon-unfold" ' \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use heredoc syntax instead of this for multiline strings.

@filename = filename
@line = line
@context = context
def initialize(filename, line, upperlines = nil, lowerlines = nil)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prior to this change, the context argument received the number of lines of context, in other words the number of lines offset from line. Shouldn't still be the case now, instead of passing nil and causing the caller/instantiator to determine which line numbers should be included?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with the context is that it tells the amount of lines to be shown without taking care of the direction.
You want 5 lines more, fine, but 5 lines more in the upper or lower direction?

This class is used in the html_formatted_code_block method from the lib/better_errors/error_page.rb file in order to tells the amount of lines in the upper and in the lower direction (from the updated frame object).

So unless I miss understood your point, keeping the context in the initialiser doesn't make sense to me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My point was that the context argument gave the number of lines of context where the variables you added take line numbers, which might even be out of bounds.

@zedtux
Copy link
Author

zedtux commented Nov 24, 2017

Thank you @RobinDaugherty for your review, I'm my code now.

@zedtux zedtux force-pushed the feature/adds-expands-to-code-view branch from 6553899 to 5323aa3 Compare November 24, 2017 10:01
@zedtux
Copy link
Author

zedtux commented Nov 24, 2017

@RobinDaugherty the code has been updated. Please feel free to review it

@zedtux
Copy link
Author

zedtux commented Dec 1, 2017

@RobinDaugherty can you please review my code?

@RobinDaugherty
Copy link
Member

Sorry @zedtux I'm not able to answer quickly, but I'm able to spend time on this project once a week or so.

@zedtux
Copy link
Author

zedtux commented Dec 6, 2017

Thank you @RobinDaugherty for your message, I'm available when you will be :)

@zedtux
Copy link
Author

zedtux commented Dec 11, 2017

@RobinDaugherty a gentle reminder for my PR :)

@zedtux
Copy link
Author

zedtux commented Dec 22, 2017

@RobinDaugherty and @charliesome a gentle reminder on this PR. I really think it's useful so I'm available for changing anything and get this thing merged :)

@zedtux
Copy link
Author

zedtux commented Jan 11, 2018

@RobinDaugherty sorry for being asking again and again but can you please check the PR and let me know if there is anything I should change? Thank you.

@zedtux
Copy link
Author

zedtux commented Jan 19, 2018

@RobinDaugherty can you please review this PR?

@zedtux
Copy link
Author

zedtux commented Jan 29, 2018

@RobinDaugherty can you please review my PR?

1 similar comment
@zedtux
Copy link
Author

zedtux commented Feb 21, 2018

@RobinDaugherty can you please review my PR?

@zedtux
Copy link
Author

zedtux commented Feb 27, 2018

Can you please have a look @RobinDaugherty? This is really useful in my day to day work.

@zedtux
Copy link
Author

zedtux commented Mar 9, 2018

@RobinDaugherty please, have a look at this PR, the changes have been made and should be fine to be merged.

@zedtux
Copy link
Author

zedtux commented Apr 4, 2018

@charliesome and @RobinDaugherty can you please have a look at my PR?

2 similar comments
@zedtux
Copy link
Author

zedtux commented Apr 20, 2018

@charliesome and @RobinDaugherty can you please have a look at my PR?

@zedtux
Copy link
Author

zedtux commented May 4, 2018

@charliesome and @RobinDaugherty can you please have a look at my PR?

@zedtux
Copy link
Author

zedtux commented Jun 8, 2018

Well ... it's now a long time ago I have oped this PR, with a review from @RobinDaugherty, who's now ignoring me and my PR ... What's the solution in order to get this merged? cc @charliesome

@zedtux
Copy link
Author

zedtux commented Jul 18, 2018

@RobinDaugherty ?

@zedtux
Copy link
Author

zedtux commented Nov 23, 2021

Really interesting the way this PR goes. Whatever ...

@zedtux zedtux closed this Nov 23, 2021
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.

2 participants