Bug 26314 Goto Matching Bracket bug with selection
20021113 1. In this code action.setChecked(elements[i].equals(fHierarchyView.getInputElement())); select the last bracket with a selection of length 1. 2. press ctrl + shift + P 3. wrong bracket is matched
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.java
return;
			final ISourceViewer sourceViewer= getSourceViewer();
			IDocument document= sourceViewer.getDocument();
			final Point selection= sourceViewer.getSelectedRange();
			final int offset= selection.x;
			final int length= selection.y;
			switch (event.character) {
			case '(':
			case '[':
					if (!fCloseBrackets)
						return;
 					if (hasIdentifierToTheRight(document, offset + length))
 						return;
			
			case '"':
				if (event.character == '"') {
					if (!fCloseStrings)
						return;
 					if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length))
 						return;
				}
				
				try {		
					ITypedRegion partition= document.getPartition(offset);
					if (! IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) && partition.getOffset() != offset)
						return;
					final char character= event.character;
					final char closingCharacter= getPeerCharacter(character);		
					final StringBuffer buffer= new StringBuffer();
					buffer.append(character);