Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Issue #11261: keep the search bar open #11996

Closed
wants to merge 26 commits into from

Conversation

pldilley
Copy link

Reference:
Issue: #11261 - "keep the search bar open"

Based on this pull request that is waiting on the user: #11692 ( @adrianhartanto0 ). However I ended up taking a different approach; upon testing I found that the original approach had hiccups. The changes are influenced by the preference idea by @zaggino and @abose in the aforementioned pull request.

Changes:

  • Added in a menu option under View to allow find bar to stay open/automatically close
  • Add a close icon to the search bar (for completeness)
  • Fix escape key for in-editor searches
  • Remember last search phrase if no selection for in-editor searches
  • Go to the next search item if the bar is open and the user clicks Find or hits ctrl+F

Testing:

  • All tests pass for FindReplace-test.js after some changes to the code I wrote and one of the tests
  • Manual testing was briefly performed as such:
    • In-Editor - Find the same item by resetting the cursor position: Pass
    • In-Editor - Find a custom item by setting the cursor position: Pass
    • In-Editor - Find the first item by setting the cursor position after the last: Pass
    • In-Editor - Cycle through the items by hitting ctrl+F while still open: Pass
    • In-Editor - Closes when the "Automatically close search" option is checked and the editor is focused: Pass
    • In-Editor - Moving to a different editor closes the search: Pass
    • In-Editor - Pre-selecting text and re-opening the search shows the newly selected text: Pass
    • In-Editor - Pre-selecting nothing and re-opening the search shows the last query: Pass
    • In-Editor - Selecting the caps and regexp options functions as expected: Pass
    • View --> Automatically close search - Preference is remembered on application restart: Pass
    • In-File: Search functions as expected, and the same tests for In-Editor, where applicable, also pass.

thejackhammer and others added 14 commits September 12, 2015 16:23
…as a result of clicking in the main editor. This is done by commenting out the code in line 256. The search bar will also close when the ESC key is pressed while the main editor has focus
…/automatically close

* Add a close icon to the search bar (for completeness)
* Fix escape key for in-editor searches
* Remember last search phrase if no selection for in-editor searches
… until I can confirm with a Quebecois at work
@pldilley pldilley changed the title Issue #11261 (via #11692) Issue #11261 Dec 12, 2015
@Denisov21
Copy link
Contributor

👍 Awersome PR!

if (editor) {
// Make note of the original query details
var state = getSearchState(editor._codeMirror),
qry = (findBar && state && state.parsedQuery) || "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Minor nitpick: this variable could be just query

@pldilley
Copy link
Author

Thanks @Denisov21 and @petetnt ! Will look into getting these fixed in the next few weeks :-)

@@ -695,6 +702,8 @@ define(function (require, exports, module) {
findBar.close();
}
}

editor.lastEditorSearchPosStr = ""; // Positions have shifted, so we abort the auto-next on findbar launch
Copy link
Author

Choose a reason for hiding this comment

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

No longer relevant - remove.

@abose
Copy link
Contributor

abose commented Jun 29, 2016

addresses #12280

@ficristo ficristo changed the title Issue #11261 Issue #11261: keep the search bar open Aug 14, 2016
@zaggino zaggino added this to the Release 1.9 milestone Aug 28, 2016
@petetnt petetnt self-assigned this Dec 8, 2016
@petetnt
Copy link
Collaborator

petetnt commented Dec 8, 2016

Welp, how has this been left on the backburner for so long. Sorry about that @pldilley! If you could fix that one conflict so we can merge this in ASAP.

Sorry again!

@pldilley
Copy link
Author

pldilley commented Dec 8, 2016

@petetnt No problem, I have a bit of time this weekend, I'll retest it too to make sure that the behaviour hasn't changed.

@swmitra
Copy link
Collaborator

swmitra commented Feb 15, 2017

Bump. Is anyone working on this PR now?

@swmitra swmitra modified the milestones: Release 1.10, Release 1.9 Mar 15, 2017
@IanButterworth
Copy link

I'd appreciate this being incorporated if anyone has the time to iron out the conflicts

@IanButterworth
Copy link

Bumping again, as I get frustrated by this issue almost every time I use brackets. Please, can this be incorporated.

@petetnt
Copy link
Collaborator

petetnt commented Jan 18, 2018

@ianshmean sorry about that, this one has slipped through our fingers somehow once again. I'll try to re-review this tomorrow.

Thanks for your patience @pldilley too!

@pldilley
Copy link
Author

Hmm, so I've resolved the merge conflicts based on master. However I haven't tested it, and am perhaps a bit too busy in life now to have time. Can someone please just do a sanity check on it before merging?

@swmitra
Copy link
Collaborator

swmitra commented Jan 19, 2018

@petetnt Once you are done with the review, I will merge this PR 👍 I was trying to merge this an year back BTW, well almost! But this thread was not active, couldn't incorporate this.

Copy link
Collaborator

@petetnt petetnt left a comment

Choose a reason for hiding this comment

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

LGTM codewise.

The new tests are failing now for some reason, not exactly sure why yet.

There's also a tiny bug where if you have the search bar open and toggle "Automatically close search" option the search bar only stays open after closing it once. However I don't think that's a blocker by any means.

👍

expect(getSearchField().val()).toEqual("Foo");
expectHighlightedMatches(capitalFooSelections);
expectSelection(capitalFooSelections[0]);
expectMatchIndex(0, 3);
expect(myEditor.centerOnCursor.calls.length).toEqual(3);

expect(myEditor).toHaveCursorPosition(8, 8, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This tests fails for me with expected the cursor to be at (8, 8) but it actually was at (2, 8) and more than one character was selected, hmm.

twCommandManager.execute(Commands.CMD_FIND_NEXT);

expect(myEditor).toHaveCursorPosition(8, 8, true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar error with this one: expected the cursor to be at (8, 8) but it actually was at (2, 31) and more than one character was selected, hmm.

@IanButterworth
Copy link

Checking in on this. Seems to still be missing in 1.12.
Still a big fan of this feature being worked in

@nethip
Copy link
Contributor

nethip commented Mar 1, 2018

@ianshmean Totally agree with you. I hope to see this PR merged as well. @pldilley Can you please have a look at the review comments posted by @petetnt and incorporate the changes, if needed?.

Copy link
Collaborator

@petetnt petetnt left a comment

Choose a reason for hiding this comment

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

LGTM, see #14141 for additional commit

@petetnt
Copy link
Collaborator

petetnt commented Mar 2, 2018

Landed in #14141 with additional commit, thanks for your patience @pldilley, @ianshmean and @adrianhartanto0

@petetnt petetnt closed this Mar 2, 2018
@pldilley
Copy link
Author

pldilley commented Mar 2, 2018

P.S. Sorry I did not get to the test fixes. I hope this code change works out :)

@nethip
Copy link
Contributor

nethip commented Mar 5, 2018

Thanks @petetnt and @pldilley for your efforts.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants