Page MenuHomePhabricator

Added "search and replace within selection" functionality
Closed, DuplicatePublic

Description

Author: kim

Description:
screenshot of functionality

https://gerrit.wikimedia.org/r/#/c/87322/

This enables users to first select some text in the textarea, and
click the checkbox labeled "Search/replace within text selection"
when searching / replacing text.
When this checkbox is checked, the text searched/replaced will a subset
of the original text determined by the user's text selection.


Version: unspecified
Severity: enhancement

Attached:

Details

Reference
bz54961
Related Gerrit Patches:
mediawiki/extensions/WikiEditor : masterAdded "search and replace within selection" functionality

Event Timeline

bzimport raised the priority of this task from to Lowest.Nov 22 2014, 2:10 AM
bzimport added a project: WikiEditor.
bzimport set Reference to bz54961.
bzimport added a subscriber: Unknown Object (MLST).
bzimport created this task.Oct 4 2013, 9:36 AM

mr.heat wrote:

Don't get me wrong: I like the feature. But I think the checkbox is odd.

What happens if nothing is selected? The checkbox must be hidden or at least disabled (grayed out). I guess nothing is selected 99% of the time and therefor the checkbox is useless 99% of the time.

What happens if I click "Find next" and then decide to enable the "within selection" checkbox? "Find next" changes the selection.

As I said I have a similar feature in my [[dewiki:User:TMg/autoFormatter]]: If something is selected it uses the selection. If nothing is selected it uses the full textarea. From what I heard from my users this works as expected.

A simple way to make this visible to the user is to change the title of the popup from "Search and replace" to "Search and replace in selection". Maybe change the button from "Replace all" to "Replace all in selection".

Related:

  • Bug 40797 (duplicate, but I'm not sure which one to close)
  • Bug 23942 (can't have "search and replace" and "insert internal link brackets without showing a popup" buttons the same time)
  • Bug 23992 ("search and replace" broken in Opera 12)

kim wrote:

(In reply to comment #1)

Don't get me wrong: I like the feature. But I think the checkbox is odd.
What happens if nothing is selected? The checkbox must be hidden or at least
disabled (grayed out). I guess nothing is selected 99% of the time and
therefor
the checkbox is useless 99% of the time.
What happens if I click "Find next" and then decide to enable the "within
selection" checkbox? "Find next" changes the selection.

This works as expected as i only fetch the selection upon opening the dialog, changes to the selection when the dialog is open does not have any effect.

As I said I have a similar feature in my [[dewiki:User:TMg/autoFormatter]]:
If
something is selected it uses the selection. If nothing is selected it uses
the
full textarea. From what I heard from my users this works as expected.
A simple way to make this visible to the user is to change the title of the
popup from "Search and replace" to "Search and replace in selection". Maybe
change the button from "Replace all" to "Replace all in selection".
Related:

  • Bug 40797 (duplicate, but I'm not sure which one to close)
  • Bug 23942 (can't have "search and replace" and "insert internal link

brackets
without showing a popup" buttons the same time)

  • Bug 23992 ("search and replace" broken in Opera 12)

As your request, i removed the checkbox and added a new title to the dialog if
there is a selection of thext when clicking on the search and replace functionality.

Did however not change any button texts, as this seems to cause very long button names, where the dialog is quite small. And it strictly isn't necessary when this is shown in the title.

mr.heat wrote:

(In reply to comment #2)

i only fetch the selection upon opening the dialog

My question is: Isn't this confusing? I can see that the selection changes in the background. When I close the dialog the changed selection stays changed. My original selection is gone. This makes it look like the function behaves different when I close and reopen the dialog and when I keep it open. Same selection seen in the background but different behavior.

Please do the following test:

  • Paste the text "12-12-12" in the textarea.
  • Select the first "12-12-".
  • Search for "12" and replace it with "3".
  • Hit "Find next" and "Replace". Should become "3-12-12".
  • Repeat. Should become "3-3-12".
  • Repeat. Should stay (!) "3-3-12".

Same test with "Replace all".

kim wrote:

Well, i did your test. and it works fine.

  • I pasted 12-12-12 in the texarea
  • I selected the first 12-12
  • I searched for 12 and replaced with 3.
  • I hit find next and replace, causing it to change to 3-12-12
  • I hit find next and replace, causing it to change to 3-3-12
  • I hit find next and replace, causing it to give me the messsage: "no more occurences found"
  • I then reset the textbox and did the same with replace all, which gave the result 3-3-12

Feel free to test it out yourself

kim wrote:

I dont reckon this as confusing, i mean if your doing a find operation, then you need to set a new selection for the found text occurrence. But i dont think this functionality was designed specifically for the find functionality. more for the replace functionality.

Change 87322 had a related patch set uploaded by Paladox:
Added "search and replace within selection" functionality

https://gerrit.wikimedia.org/r/87322

Please review the patch by Paladox.

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptAug 5 2015, 9:41 AM

Change 87322 had a related patch set uploaded (by Paladox):
Added "search and replace within selection" functionality

https://gerrit.wikimedia.org/r/87322

happy5214 moved this task from Backlog to Closed on the WikiEditor board.Aug 4 2019, 12:01 PM