godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
90.53k stars 21.08k forks source link

Search & Replace omits first occurence when selected beforehand but the cursor being behind #41341

Open artism90 opened 4 years ago

artism90 commented 4 years ago

Godot version:

3.2.3.rc3 (verified also on 3.2.2 stable)

OS/device including version:

Windows 10

Issue description:

When marking a word via double-click to use it for step-wise Search & Replace, the selected word isn't taken into account, but the succeeding occurrence. Apparently it's solely cursor dependant and in most cases the cursor is located after the selected word when double-clicking in the middle area of the text.

Steps to reproduce: Create new_script.gd and paste a code with several occurences:

extends Node

func _ready() -> void:
    pass
    pass
    pass
    pass
    pass
  1. With the mouse, double-click the first pass.
  2. Press CTRL+ R.
  3. Type "replaced" into the replace field.
  4. Hit Replace.
  5. Watch the second pass be replaced, effectively omitting the first (selected) one.

Current workaround: Double-click the word carefully at the left edge, so that the cursor remains in front of the word and thus takes it into account for Search & Replace.

duianto commented 1 year ago

This is a duplicate of: "Replace" doesn't take effect on current text if selected from left to right #33315

That issue was closed as completed by the PR: Fix some bugs about search in code editor #61776

The PR author explained the fix as:

Well, now when there is a selection, searching and replacing is performed from the beginning of the selection.

The issue is not reproducible in: v4.0.beta5.official [89a33d28f]

But the issue is reproducible in: v3.5.1.stable.official [6fed1ffa3]