Skip to content

Commit

Permalink
Clear search string after end of the search
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaraslaut committed Dec 17, 2024
1 parent a494b24 commit 4442161
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@
<release version="0.5.2" urgency="medium" type="development">
<description>
<ul>
<li>Fixes search editor preservation bug on exit from search mode</li>
<li>Expose current profile's name through env var `CONTOUR_PROFILE` (#1637)</li>
<li>Add terminal tabs (#90)</li>
<li>Add `SaveScreenshot` and `CopyScreenshot` action (#210)</li>
Expand Down
12 changes: 12 additions & 0 deletions src/vtbackend/ViInputHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,10 @@ void ViInputHandler::setMode(ViMode theMode)
clearPendingInput();

_executor->modeChanged(theMode);

// clear search term when switching to insert mode
if (_viMode == ViMode::Insert)
clearSearch();
}

Handled ViInputHandler::sendKeyPressEvent(Key key, Modifiers modifiers, KeyboardEventType eventType)
Expand Down Expand Up @@ -449,12 +453,14 @@ Handled ViInputHandler::handleSearchEditor(char32_t ch, Modifiers modifiers)
setMode(ViMode::Insert);
_searchEditMode = SearchEditMode::Disabled;
_executor->searchCancel();
_executor->updateSearchTerm(_searchTerm);
break;
case '\x0D'_key:
if (_settings.fromSearchIntoInsertMode && _searchEditMode == SearchEditMode::ExternallyEnabled)
setMode(ViMode::Insert);
_searchEditMode = SearchEditMode::Disabled;
_executor->searchDone();
_executor->updateSearchTerm(_searchTerm);
break;
case '\x08'_key:
case '\x7F'_key:
Expand Down Expand Up @@ -575,4 +581,10 @@ void ViInputHandler::setSearchModeSwitch(bool enabled)
_settings.fromSearchIntoInsertMode = enabled;
}

void ViInputHandler::clearSearch()
{
_searchTerm.clear();
_executor->updateSearchTerm(_searchTerm);
}

} // namespace vtbackend
1 change: 1 addition & 0 deletions src/vtbackend/ViInputHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class ViInputHandler: public InputHandler
void startSearchExternally();

void setSearchModeSwitch(bool enabled);
void clearSearch();

private:
enum class ModeSelect : uint8_t
Expand Down

0 comments on commit 4442161

Please sign in to comment.