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

Add a spec for search, #605 #3299

Merged
merged 18 commits into from
Dec 14, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added doc/specs/#605 - Search/images/AutoSuggestBox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
91 changes: 91 additions & 0 deletions doc/specs/#605 - Search/spec.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
author: Kaiyu Wang KaiyuWang16/kawa@microsoft.com
created on: 2019-10-16
last updated: 2019-10-16
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
issue id: #605
---

# Search in Terminal

## Abstract

This spec is for feature request #605 "Search". It goes over the details of a new feature that allows users to search text in Terminal, within one tab or from all tabs. Expected behavior and design of this feature is included. Besides, future possible follow-up works are also addressed.

## Inspiration

One of the superior features of iTerm2 is it's content search. The search comes in two variants: search from active tab and search from all tabs. In almost any editor, there is an roughly equivalent string search. We also want to realize search experience in Terminal. There will be two variants, search within one tab or from multiple tabs. We will start with one-tab search implementation.

## Solution Design

Our ultimate goal is to provide both search within one tab and search from all tabs experiences. But we can start with one-tab search. The search experience should have following features:

1. The search is triggered by keybindings "Ctrl + F". This coincides with other editors. In the future we will also consider adding a "Find" in the dropdown menu.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
2. The user search in a XAML AutoSuggestBox on the top right corner of the Terminal window.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
3. We can have multiple search methods. The simplest one is text exact match. Other match methods include case-sensitive exact match and regex match. In the first phrase, we will focus on case sensitive/insensitive text exact match.
4. If currently there is no active selection, the search starts from the line that the cursor is on. If there is an active selection, we start from the previous or the next text of the selected text. We automatically go around if we reach the start point of the search.
5. The search dialog should not block terminal's view.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

Conhost already has a module for search. It realizes case sensitive or insensitive exact text match search, and it provides methods to select the found word. However, we want to make search as a shared component between Terminal and Console host. Now search module is part of Conhost, and its dependencies include BufferOut and some other types in ConHost such as SCREEN_INFORMATION. In order to make Search a shared component, we need to remove its dependency on ConHost types. BufferOut is already a shared component, but we need to make sure there is no other Conhost dependency.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

Search process:
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
Search is performed on a XAML AutoSuggestBox. Once the user click the "Find" icon, we start from the cursor (or the current selection), and try to find the exact text in the text buffer. The nearest searched one will be selected. And we set the search start point to the selected text. The next time "Find" button is clicked, the search will start before or after the previous searched text.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
The user can choose to search up or down by choosing up arrow or down arrow buttons.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
The user can choose to do case sensitive or insensitive match by clicking a button.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
If the user click the "X" button, the search stopped and the search box disappears. In phrase one we do not store any state, but in the future we can consider storing the search history.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
## UI/UX Design
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

![Sol Design](images/AutoSuggestBox.png)
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

Above is the XAML AutoSuggestBox. We also need to add at least two more buttons, one for case sensitive/insensitive switch, and one for search direction switch. We can consider adding the buttons on the right side of the AutoSuggestBox.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

The search box should be on the top right corner of the Terminal window. We need to avoid it blocking too much screen contents.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
## Capabilities

1. The user can search exact matched text in the text buffer of the Terminal Screen.
2. The user can choose to search case sensitively and insensitively.
3. The user can search up or down.
4. Found text will be selected.
5. The search will start from the active selected text (inclusive) if there is one, or where the cursor is.
5. The search will automatically go around when it reaches the starting point.

### Accessibility

This feature could help multitaksing terminal users.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

### Security

This feature should not introduce any new security issues.

### Reliability
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

This feature enable users to search for text in the terminal input/output history. This is a widely-used feature in most editors and thus improve the reliability of Terminal once added.

### Compatibility

This feature won't break existing features of Terminal.

### Performance, Power, and Efficiency

This feature only launches in need. It does not impact the performance of Terminal.

## Potential Issues
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved

1. The search bar should not block command line view.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
2. Search should not block any program the Terminal is currently executing.

## Future considerations
Copy link
Member

Choose a reason for hiding this comment

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

Can you create follow-up work items for these and link them here?


In version 1, we want realize a case sensitive/insensitive exact text match. But we may consider the following features in version 2:

1. Add "Find" button in dropdown menu to trigger search.
Copy link
Member

Choose a reason for hiding this comment

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

As an addition (or replacement) to this point, this may also be a good feature for the command palette #2046 . You and @zadjii-msft should talk about this one 😊

2. Search from all tabs. For Version 1 we just want to realize search within one tab. However, the community also requests search from all tabs. We put in our goals for Version 2.
3. Regular experssion match.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved
4. Search history.
5. High-light while you type.
KaiyuWang16 marked this conversation as resolved.
Show resolved Hide resolved


## Resources

Github Issue: https://github.com/microsoft/terminal/issues/605