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

Show a gap between ranges of lines in search results #27

Closed
simonw opened this issue Dec 14, 2022 · 3 comments
Closed

Show a gap between ranges of lines in search results #27

simonw opened this issue Dec 14, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Dec 14, 2022

https://ripgrep.datasette.io/-/ripgrep?pattern=asgi_s&literal=on&glob=datasette%2F**

This is a bit confusing. There should ideally be visual gaps in the line numbers here to make it easier to spot the different ranges:

CleanShot 2022-12-14 at 15 55 39@2x

@simonw simonw added the enhancement New feature or request label Dec 14, 2022
@simonw
Copy link
Owner Author

simonw commented Dec 14, 2022

Here's what the HTML looks like:

<pre><a class="line-number" href="/-/ripgrep/view/datasette/datasette/app.py#L87">87  </a><span>)
</span></pre>
<pre><a class="line-number" href="/-/ripgrep/view/datasette/datasette/app.py#L88">88  </a><span>from .utils.internal_db import init_internal_db, populate_schema_tables
</span></pre>
<pre><a class="line-number" href="/-/ripgrep/view/datasette/datasette/app.py#L200">200 </a><span>
</span></pre>

From this template:

{% for result in results %}
{% if result.type == "begin" %}
<h3>{{ fix_path(result.data.path.text) }}</h3>
<div style="overflow-x: auto">{% set ns.ended = false %}
{% endif %}
{% if result.type in ("match", "context") %}
<pre{% if result.type == "match" %} class="match"{% endif %}><a class="line-number" href="{{ urls.path("/-/ripgrep/view/" + url_quote(fix_path(result.data.path.text))) }}#L{{ result.data.line_number }}">{{ "%-4s" | format(result.data.line_number) }}</a><span>{{ result.data.lines.text }}</span></pre>
{% endif %}
{% if result.type == "end" %}{% set ns.ended = true %} </div>{% endif %}
{% endfor %}

@simonw
Copy link
Owner Author

simonw commented Dec 14, 2022

So maybe I need to detect when line of code has a line number that's more than one higher than the previous one and add an extra class, maybe <pre class="line-jump"> which can have some extra margin.

@simonw simonw closed this as completed in 9921ebb Dec 15, 2022
@simonw
Copy link
Owner Author

simonw commented Dec 15, 2022

simonw added a commit that referenced this issue Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant