Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 374923

Summary: Editor hangs on a zero-length regexp match
Product: [ECD] Orion Reporter: Mark Macdonald <mamacdon>
Component: EditorAssignee: Silenio Quarti <Silenio_Quarti>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: libingw, Silenio_Quarti
Version: 0.5   
Target Milestone: 0.5 M1   
Hardware: PC   
OS: All   
Whiteboard:

Description Mark Macdonald CLA 2012-03-21 11:06:26 EDT
Orion I20120319-2230

1. Open an editor on plugin.js from the Orion source code.
2. Press Ctrl+F. Check "Regular expression".
3. Type in this query: \b
(This is a valid regexp that will match, but the match consumes zero characters)
4. Editor hangs.

The code incorrectly assumes that repeatedly calling RegExp.prototype.exec() will eventually return null. When a zero-length match is encountered, subsequent exec() calls return the same result. At this point you're stuck.

One approach is to treat a zero-length match as "not found", and terminate the search. This seems to be what the Eclipse desktop editor does. This makes sense because you can't present a zero-width match in the editor anyway (there's nothing to highlight).
Comment 1 libing wang CLA 2012-03-21 11:24:33 EDT
Silenio just pushed the new text model API.
I just pulled and the issue disappeared.
Please double check.
Comment 2 Mark Macdonald CLA 2012-03-21 11:51:31 EDT
I can still reproduce the problem using the code in HEAD.
Comment 3 libing wang CLA 2012-03-21 13:37:18 EDT
(In reply to comment #2)
> I can still reproduce the problem using the code in HEAD.

You are right. I was searching on an empty file.
Comment 4 Silenio Quarti CLA 2012-03-22 10:50:15 EDT
I changed textModel.js to abort the search for zero-length matches.

Fixed
http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=d8f854c6302d1ecffb821114ffdd336793d0fbec