Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Find and Replace fails to replace all finds #3631

Open
1 task done
djhenderson opened this issue May 9, 2024 · 1 comment
Open
1 task done

[Bug]: Find and Replace fails to replace all finds #3631

djhenderson opened this issue May 9, 2024 · 1 comment

Comments

@djhenderson
Copy link

What did you do?

I have a SQL tab containing:

INSERT INTO skills(name, seq, skill)
VALUES	('Joe', 1, '')
,	('Joe', 2, '')
,	('Joe', 3, '')
,	('Joe', 4, '')
,	('Joe', 5, '')
,	('Joe', 6, '')
;
  1. I Select All the text.
  2. I open the Find and Replace dialog with Find text Joe and Replace with Josephine and only Selection only checked.
  3. I click Replace All.

The result is:

INSERT INTO skills(name, seq, skill)
VALUES	('Josephine', 1, '')
,	('Josephine', 2, '')
,	('Josephine', 3, '')
,	('Josephine', 4, '')
,	('Josephine', 5, '')
,	('Joe', 6, '')
;

If I use a longer repacement text, such as Josephine Geraldine Smith this is the result:

INSERT INTO skills(name, seq, skill)
VALUES	('Josephine Geraldine Smith', 1, '')
,	('Josephine Geraldine Smith', 2, '')
,	('Josephine Geraldine Smith', 3, '')
,	('Joe', 4, '')
,	('Joe', 5, '')
,	('Joe', 6, '')
;

If I use the expected text as show below, with Find text Josephine Geraldine Smith and Replace with of Joe and select only the first two lines containing the Find text. This is the result:

INSERT INTO skills(name, seq, skill)
VALUES	('Joe', 1, '')
,	('Joe', 2, '')
,	('Joe', 3, '')
,	('Josephine Geraldine Smith', 4, '')
,	('Josephine Geraldine Smith', 5, '')
,	('Josephine Geraldine Smith', 6, '')
;

Three instances are changed, even though only two instances were in the selected text.

What did you expect to see?

After the Find and Replace in the last case, I expect to see:

INSERT INTO skills(name, seq, skill)
VALUES	('Josephine Geraldine Smith', 1, '')
,	('Josephine Geraldine Smith', 2, '')
,	('Josephine Geraldine Smith', 3, '')
,	('Josephine Geraldine Smith', 4, '')
,	('Josephine Geraldine Smith', 5, '')
,	('Josephine Geraldine Smith', 6, '')
;

In the second case, I expected that only the instances in the selected text would be changed.

What did you see instead?

The Find and Replace did not change all strings that matched the Find text when the Replace with string is longer than the find string. Also, when the replacement string is shorter than the Find text string, instances outside the selection can be changed.

I would guess that the end of search range is not adjusted along with the size of the search text is it is changed by the replacements when replacements are done top to bottom. This is not necessary when the replacements are performed from bottom to top.

DB4S Version

3.13.99 (nightly)

What OS are you seeing the problem on?

Windows

OS version

Microsoft Windows [Version 10.0.19045.4355]

Relevant log output

From the About dialog:

DB Browser for SQLite Version 3.13.99 (Feb  8 2024)
Last commit hash when built: c315df7

Built for x86_64-little_endian-llp64, running on x86_64
Qt Version 5.15.2
SQLite Version 3.45.1.

Prevention against duplicate issues

  • I have searched for similar issues
@stefanofraccaro
Copy link

I can confirm the bug also on 3.13.0-rc1 . It seems that search-replace is done on original text length. The bug happens only when the new text is longer than the original.

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

No branches or pull requests

2 participants