Sourcegraph: Add button to search results page to change search.contextLines

Created on 15 Mar 2019  路  4Comments  路  Source: sourcegraph/sourcegraph

A customer remarked that the new search.contextLines (which controls how many lines of context are shown for search result matches) is "tedious if I want to change it" because they must go into user settings, edit JSON, save, and then go back. It is also hard to discover (we explicitly told this user about it). These are the problems we need to address.

A button on the search results page to set the number of context lines would address these problems. It would change the value in user settings (there would not be a way, via the button, to change it in global/org settings, but we expect users/admins would understand how to do so manually).

If possible with the current keyboard shortcuts framework we have, it would be good for the hotkey for this button (assuming it is a dropdown) to be Shift-C to match grep -C.

Design questions: is it a dropdown, how does it coexist with other buttons on the search results page, do we start to roll all them up into a gear menu, etc.

Requested by https://app.hubspot.com/contacts/2762526/company/407948923

(Edit: I changed my mind and now think it should be a search keyword as well, thanks to the comment below at https://github.com/sourcegraph/sourcegraph/issues/2754#issuecomment-600339681. Adding a search keyword is tracked in https://github.com/sourcegraph/sourcegraph/issues/2432#issuecomment-47300193. I have quoted my original comment portion that I no longer agree with below:

Note that in https://github.com/sourcegraph/sourcegraph/issues/2432#issuecomment-473001938 we discussed the possibility of adding a search keyword, like context:7 or C:7 (meaning show 7 context lines), but I think a button is better because:

  • It avoids adding a new place that this setting could come from
  • It is more discoverable
  • I am not aware of (and can't think of significant) use cases where this truly needs to be per-query (and the user isn't OK with just using the button)
customer feature-request needs-design teasearch

Most helpful comment

@troshko111 Thank you. This is a great point. I have edited my top comment and reopened https://github.com/sourcegraph/sourcegraph/issues/2432#issuecomment-47300193, which tracks adding a search keyword to control the context lines.

All 4 comments

Quick improvement here that can ship in 3.2: https://github.com/sourcegraph/sourcegraph/pull/2755

馃憤

@sqs

I was just trying to find a specific API usage anti-pattern and required couple lines of context (-A/-B or just -C in grep terminology), the first thing I looked into was the search syntax help page, after I could not find it there, I googled for this on GitHub and found the linked issue and this one. And only here I learned the settings page existed in the first place, let alone one can configure context lines there. This is my anecdote to counter these assumptions:

but I think a button is better because:

It avoids adding a new place that this setting could come from
It is more discoverable
I am not aware of (and can't think of significant) use cases where this truly needs to be per-query (and the user isn't OK with just using the button)

So the users are trained to use the search syntax and refer to its help when they need something unusual / new, it's also much more flexible as it can be specified per query. I don't need huge context 99% of the time, but for some specific use cases I do and I'd rather specify it right there, than change the global settings and (forget to) change them back.

It's like if grep only supported specifying -A/-B/-C via a config file. Probably ok to specify the _defaults_, but must have a way to override per query.

My $0.02: allow specifying the _default_ in settings, add an ability to _override_ per query via search syntax, optionally add a button to insert the special keyword to improve discoverability.

@troshko111 Thank you. This is a great point. I have edited my top comment and reopened https://github.com/sourcegraph/sourcegraph/issues/2432#issuecomment-47300193, which tracks adding a search keyword to control the context lines.

Was this page helpful?
0 / 5 - 0 ratings