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

Bug 298065

Summary: resetCreationTarget of CSSModelParser.java in org.eclipse.wst.css.core behaves incorrectly
Product: [WebTools] WTP Source Editing Reporter: Badrinarayan <badri_ravi83>
Component: wst.cssAssignee: wst.css <wst.css-inbox>
Status: CLOSED DUPLICATE QA Contact: Nick Sandonato <nsand.dev>
Severity: normal    
Priority: P3 CC: nsand.dev
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Badrinarayan CLA 2009-12-17 07:04:09 EST
Build Identifier: 

resetCreationTarget of CSSModelParser.java in org.eclipse.wst.css.core behaves incorrectly .
Earlier in the code 
		if (cursorNode == node) {
			// v<--|
			// AAAAAA
			// BBBBBBBBBB cursorNode:A , node:B -> target is A
			if (bOverOpenBrace && cursorNode instanceof CSSRuleDeclContainer) {
				targetNode = (CSSNodeImpl) ((CSSRuleDeclContainer) cursorNode).getStyle();
			}

			
			else {
				targetNode = cursorNode;
			}
		}
the targetNode was initialized correctly with cursorNode if first if fails.
but a new 			else if(cursorPos == newStructuredDocumentRegion.getStartOffset() && cursorNode.getParentNode() != null) {
				targetNode = (CSSNodeImpl)cursorNode.getParentNode();
}
has been added because of which targetNode is always assigned cursorNode.getParentNode() if the first if fails and never it comes to else part
(int cursorPos = newStructuredDocumentRegion.getStartOffset() is done earlier in the code and cursor position value doesn't change)
So there are exceptions caused later.

This is because of fix for 
Bug 284583 -  Stack Overflow caused by infinite loop in the CSS Outline 

Reproducible: Always
Comment 1 Badrinarayan CLA 2009-12-17 07:50:09 EST
Build Identifier: v200911162000
Comment 2 Nick Sandonato CLA 2009-12-18 09:45:26 EST
Thanks for the report. Ian's looking at this in Bug 298111.

*** This bug has been marked as a duplicate of bug 298111 ***