This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 119925 - Warnings displayed during search & replace on HTML files
Summary: Warnings displayed during search & replace on HTML files
Status: RESOLVED FIXED
Alias: None
Product: utilities
Classification: Unclassified
Component: Search (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Marian Petras
URL:
Keywords:
: 129510 (view as bug list)
Depends on:
Blocks:
 
Reported: 2007-10-24 15:42 UTC by Jesse Glick
Modified: 2008-03-20 14:45 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Stack traces (6.64 KB, text/plain)
2007-10-24 15:43 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2007-10-24 15:42:29 UTC
I tried to substitute a string over src/ and javahelp/ in my project. All substitutions were carried out correctly, but
for each *.html matches in javahelp/ I was warned (with a separate dialog!) that the IDE could not get a write lock. All
files were writable. See stack trace; looks like the search & replace code asks for the encoding of the file *after*
opening it for writing, which will not work for file types which sniff the header (in read mode) to determine the encoding.

In fact it looks like a (C) character in an unrelated part of the document was replaced with the UTF-8 version despite
the ISO-8859-1 encoding declaration, which is consistent with the hypothesis that the IDE fell back to the project
encoding (UTF-8). Whether Search & Replace should really be modifying lines in the document which do not match the
search expression is another question; arguably a lower-priority bug.
Comment 1 Jesse Glick 2007-10-24 15:43:08 UTC
Created attachment 51587 [details]
Stack traces
Comment 2 Marian Petras 2007-10-30 17:12:36 UTC
Thanks for the report. I will fix it in the next release (or a module update).
Comment 3 Jesse Glick 2007-10-30 22:18:51 UTC
I think this is a P3 bug - besides the annoying warnings, the file contents were corrupted where non-ASCII characters
appeared, even far from search hits. There is no permanent data loss (since we now have local history), but trying to
revert such bogus changes could still be a real headache if you had a lot of HTML files.
Comment 4 Marian Petras 2008-03-19 17:51:15 UTC
*** Issue 129510 has been marked as a duplicate of this issue. ***
Comment 5 Marian Petras 2008-03-20 14:45:35 UTC
Fixed.

I changed the code such that the query about each file's encoding is executed only once (during search) and the same
encoding is then used when replacing.

Modified files:
    utilities/src/org/netbeans/modules/search/BasicSearchCriteria.java
    utilities/src/org/netbeans/modules/search/MatchingObject.java
    utilities/src/org/netbeans/modules/search/ResultModel.java
    utilities/src/org/netbeans/modules/search/SearchTask.java
    utilities/src/org/netbeans/modules/search/SpecialSearchGroup.java

Changeset Id:
572797b41915
(http://hg.netbeans.org/main/rev/572797b41915)