Skip to content

Search: Remove unnecessary whitespace in case if we remove part of the string

Administrator requested to merge vk/fix-replace-range into main

Created by: vovakulikov

Fixes https://github.com/sourcegraph/sourcegraph/issues/41452

This PR removes unnecessary in case if we remove something from the query. We do it in a few cases. For example when we extract from the query filters that are supposed to be a part of UI (pattern type and case: filters)

Prior to this PR: on the homepage we have insights case:yes repo: sourcegraph/sourcegraph on the search result page we have insights repo:sourcegraph/sourcegraph (note that between search pattern insights and repo filter there is an additional space)

In this PR on the homepage we have insights case:yes repo: sourcegraph/sourcegraph on the search result page we have insights repo:sourcegraph/sourcegraph Note that there is only one space between insights and repo filters

Test plan

  • Search any querh that has filters that are supposed to be remove from the query and become part of UI controls (like pattern type or case: filters) for example insights case:yes patterntype:regex repo:sourcegraph/sourcegraph
  • On the search result page you should see that there are no whitespaces between parts that are still in the query (like insights repo:sourcegraph/sourcegraph, note that between search pattern and repo filter is no spaces)
  • Click different fitlers in the search sidebar panel like search types (find a symbol or search diffs), make sure that query is not currapted and still is valid after changing it through those filters.

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading