-
Notifications
You must be signed in to change notification settings - Fork 197
Unhelpful behavior with "Only in Selection" search and no selection #1101
Comments
You can add this to your keymap: '.platform-win32 .find-and-replace':
'ctrl-alt-s': 'find-and-replace:toggle-selection-option' Then in the situation you describe where pressing Enter doesn't move past the first result, you can use this (or whatever keybinding you want) to disable |
I would suggest on display of find/replace panel, if the user has something selected then it defaults the "Selection only" on. The user can then unselect text in the editor or unselect the "Selection only" as desired. |
It seems to be a bit worse than that, to me. Here's what I'm seeing, at least in Atom 1.56.0 on Linux x86_64 — behavior confirmed even with
Inspecting the DOM with the dev console, it seems that Atom does draw a distinction between <div class="highlights style="style="contain: strict; position: absolute;
overflow: hidden; user-select: none; height: 48279px; width: 920px;">
<!-- A mouse selection creates one or more (depending on the shape) of these: -->
<div class="highlight selection">...</div>
<!-- "Find All" creates, for N matches, N-1 of these: -->
<div class="highlight find-result">...</div>
<!-- And exactly one of these: -->
<div class="highlight current-result">...</div>
<!-- ...But it **also** replaces the previous selection with N of these: -->
<div class="highlight selection">...</div>
<!-- Whereas "Find" simply replaces the previous selection with
a single one of these, which follows the current-result: -->
<div class="highlight selection">...</div> Because activating any "Find" command for some reason blows away the user's text selection in favor of selecting some or all of the results (even though those selections are redundant with the |
I would flip that around slightly, and make "Find in selection" default to the entire buffer, if nothing is selected. That way, the toggle for "Find in selection" never has to auto-enable, it can be persisted across uses of the find panel or even entire Atom sessions, and it effectively becomes a preference switch to activate/deactivate the search behavior you describe, just without the magical auto-enabling. Reversing it like that means that people who never want "Find in selection" can just leave it toggled off, it'll stay toggled off, and nobody is ever forced to unselect text or toggle switches to scope search the way they want it. |
Heh! I discovered there was an old plugin to do exactly that (atom-auto-replace-in-selection). Turns out, getting the logic right on that can be trickier than it seems. (It's a common pattern to select something, copy, then pull up Find: and paste into it. A naive auto-find-in-selection implementation can break that pattern.) |
Prerequisites
Description
If you have the "Only in Selection" toggle enabled, then search the current buffer without any selection currently highlighted, the search automatically highlights the first result. This means that attempts to proceed to the next search match within the document fail, as the search then collapses to encompass only that first hit. It ends up being a nuisance behavior, as it never feels expected and requires that the user then toggle the search mode and start over.
I frequently run into this as I tend to alternate between in-selection and full-document searches and search-replace ops.
Steps to Reproduce
Expected behavior:
Search moves from one hit to the next, as if you were in selection-agnostic search mode
Actual behavior:
The search finds the first hit, then stops and loops over that result repeatedly
Reproduces how often:
100%
Versions
Atom : 1.40.1
Electron: 3.1.10
Chrome : 66.0.3359.181
Node : 10.2.0
Atom : 1.40.1
Electron: 3.1.10
Chrome : 66.0.3359.181
Node : 10.2.0
Windows 10 Home version 1809
Additional Information
Some possible solutions or mitigating changes:
The text was updated successfully, but these errors were encountered: