Add button to search results page to change search.contextLines
Created by: sqs
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
orC: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)
2021-11-06 From @benvenker: Example from customer via Atom editor: