Search in files and Find do not work with non-Latin characters
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 72/100
Hướng nghiên cứu
Người báo cáo nêu hai chỗ bọc search text trong \b cho whole-word matching: FindReplaceDocumentAdapter trong org.eclipse.jface.text và PatternConstructor.java trong org.eclipse.search.core. Compile các pattern đó với Pattern.UNICODE_CHARACTER_CLASS để word boundary vẫn Unicode-aware trên JDK 21+. Xác nhận Find và Search in files vẫn match các whole word không Latin; issue không nêu extra test nào.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem description
In my Eclipse based product (sorry it is not open source), we found that in particular scenarios (such as "whole word only") Search in files and Find do not work with non-Latin characters with JDK later than v21.
To implement "whole word only", Eclipse code created a regex with the text surrounded by "\b". It is not processed correctly.
We assumed that the problem is in Java SDK and opened a ticket for them, but it was rejected with the following explanation:
The '\b' meta character behaviour has been changed in Semeru 21 or later versions. The change has been implemented because of the below OpenJDK issue.
OpenJDK Issue and Java 19 Release Note:
-----------------------------------------------------
[https://bugs.openjdk.org/browse/JDK-8282129](https://urldefense.proofpoint.com/v2/url?u=https-3A__bugs.openjdk.org_browse_JDK-2D8282129&d=DwQCaQ&c=BSDicqBQBDjDI9RkVyTcHQ&r=fhaoxtVu0e-iwX8nTZK86CwLEQtEiHmql8Am2TrpEK0&m=H0KLuEUYnT2W6zyi-I9erLSamgGyMUIx8jd872LgBl6Fxu5TvjUErd3pRBZT9FfQ&s=xW2STSDLKBbXNKOOMdqIGA3uJTJVGYmyVnhEDKEZxWU&e=)
[https://www.oracle.com/java/technologies/javase/19-relnote-issues.html#JDK-8264160](https://urldefense.proofpoint.com/v2/url?u=https-3A__www.oracle.com_java_technologies_javase_19-2Drelnote-2Dissues.html-23JDK-2D8264160&d=DwQCaQ&c=BSDicqBQBDjDI9RkVyTcHQ&r=fhaoxtVu0e-iwX8nTZK86CwLEQtEiHmql8Am2TrpEK0&m=H0KLuEUYnT2W6zyi-I9erLSamgGyMUIx8jd872LgBl6Fxu5TvjUErd3pRBZT9FfQ&s=9YDXr169fPzu3GN1s9KGaGhBBJXFuabt2Pq5jceny18&e=)
In Semeru 18 or earlier version, The \b was by default unicode aware. So it was able to process the Hebrew characters successfully.
However in Semeru 21 or later version, the \b meta character matches ASCII word characters by default. To match Hebrew string, the UNICODE_CHARACTER_CLASS must be set because it contains unicode characters.
How to set UNICODE_CHARACTER_CLASS ?
-----------------------------------------------------------------
Pattern pattern = Pattern.compile(findString, Pattern.UNICODE_CHARACTER_CLASS);
Reason behind the change:
------------------------------------------
In Semeru 18 or earlier versions, the \b (word boundary) behaviour was inconsistent with \w (word character) behaviour. The \w (word character) matches [a-zA-Z_0-9] in the absence of UNICODE_CHARACTER_CLASS being set. However the \b relies on j.l.Character.isLetterOrDigit along with a check for underscores and isLetterOrDigit method matches some unicode characters in addition to the range specified by \w (word character). However when UNICODE_CHARACTER_CLASS is set, the character range of both \w and \b is consistent.
In Semeru 21 or higher version, the \b and \w behaviour will be consistent whether UNICODE_CHARACTER_CLASS is set or not. The \b matcher is now uses ASCII_WORD() predicate in java.util.regex.CharPredicates to get the same range of characters as \w for determining word boundaries.
I am aware about two files where the change is required: FindReplaceDocumentAdapter class of org.eclipse.jface.text and PatternConstructor.java of org.eclipse.search.core.
Please set UNICODE_CHARACTER_CLASS there.
AFAIK there are no side effects for the change.
Tested under this environment:
- OS & version: Windows 11
- Eclipse IDE/Platform version (as shown in Help > About): Version: 2024-03 (4.31.0)
Community
- I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.
- Ngôn ngữ chính
- Java
- Star
- 124
- Fork
- 269
- Merge trung bình
- 2 ngày 3 giờ
- Pull request đã merge (30 ngày)
- 69
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của eclipse-platform/eclipse.platform.ui
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
eclipse-platform/eclipse.platform.ui#4125 · 4 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
eclipse-platform/eclipse.platform.ui#4016 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
eclipse-platform/eclipse.platform.ui#2687 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
enhancement
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
eclipse-platform/eclipse.platform.ui#4487 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Provide a shared color blend helper in JFaceCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 18/100
eclipse-platform/eclipse.platform.ui#4486 · 3 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của eclipse-platform/eclipse.platform.ui
Issue tương tự
-
agent-java community triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
elastic/apm-agent-java#4594 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/plugin good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
kestra-io/plugin-soda#137 ·
-
area/plugin good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
kestra-io/plugin-aws#816 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
area/plugin good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
kestra-io/plugin-kestra#200 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug untriaged
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 92/100
opensearch-project/search-relevance#618 ·
Maintainer thường phản hồi trong vòng 3 ngày