mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
Bug 342898 - Outline View does not fill backward history
This commit is contained in:
parent
e69cac0b3a
commit
6945632db0
3 changed files with 156 additions and 102 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2000, 2010 QNX Software Systems and others.
|
* Copyright (c) 2000, 2011 QNX Software Systems and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -283,7 +283,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
|
||||||
*
|
*
|
||||||
* @return the find/replace document adapter.
|
* @return the find/replace document adapter.
|
||||||
*/
|
*/
|
||||||
private FindReplaceDocumentAdapter getFindRepalceDocumentAdapter() {
|
private FindReplaceDocumentAdapter getFindReplaceDocumentAdapter() {
|
||||||
if (fFindReplaceDocumentAdapter == null) {
|
if (fFindReplaceDocumentAdapter == null) {
|
||||||
IDocument doc = getDocumentProvider().getDocument(getEditorInput());
|
IDocument doc = getDocumentProvider().getDocument(getEditorInput());
|
||||||
fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(doc);
|
fFindReplaceDocumentAdapter= new FindReplaceDocumentAdapter(doc);
|
||||||
|
@ -314,7 +314,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
var = var.substring(0, len);
|
var = var.substring(0, len);
|
||||||
}
|
}
|
||||||
IRegion region = getFindRepalceDocumentAdapter().find(start, var, true, true, true, false);
|
IRegion region = getFindReplaceDocumentAdapter().find(start, var, true, true, true, false);
|
||||||
|
|
||||||
if (region != null) {
|
if (region != null) {
|
||||||
len = region.getOffset();
|
len = region.getOffset();
|
||||||
|
@ -322,6 +322,7 @@ public class MakefileEditor extends TextEditor implements ISelectionChangedListe
|
||||||
getSourceViewer().revealRange(len, length);
|
getSourceViewer().revealRange(len, length);
|
||||||
// Selected region begins one index after offset
|
// Selected region begins one index after offset
|
||||||
getSourceViewer().setSelectedRange(len, length);
|
getSourceViewer().setSelectedRange(len, length);
|
||||||
|
markInNavigationHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1938,66 +1938,92 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
||||||
* @param moveCursor if true the editor is scrolled to show the range.
|
* @param moveCursor if true the editor is scrolled to show the range.
|
||||||
*/
|
*/
|
||||||
public void setSelection(ISourceRange element, boolean moveCursor) {
|
public void setSelection(ISourceRange element, boolean moveCursor) {
|
||||||
|
if (getSelectionProvider() == null)
|
||||||
if (element == null) {
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ISelection selection= getSelectionProvider().getSelection();
|
||||||
|
if (selection instanceof ITextSelection) {
|
||||||
|
ITextSelection textSelection= (ITextSelection) selection;
|
||||||
|
// PR 39995: [navigation] Forward history cleared after going back in navigation history:
|
||||||
|
// mark only in navigation history if the cursor is being moved (which it isn't if
|
||||||
|
// this is called from a PostSelectionEvent that should only update the magnet)
|
||||||
|
if (moveCursor && (textSelection.getOffset() != 0 || textSelection.getLength() != 0))
|
||||||
|
markInNavigationHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (element != null) {
|
||||||
IRegion alternateRegion = null;
|
|
||||||
int start = element.getStartPos();
|
StyledText textWidget= null;
|
||||||
int length = element.getLength();
|
|
||||||
|
ISourceViewer sourceViewer= getSourceViewer();
|
||||||
|
if (sourceViewer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
textWidget= sourceViewer.getTextWidget();
|
||||||
|
if (textWidget == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// Sanity check sometimes the parser may throw wrong numbers.
|
try {
|
||||||
if (start < 0 || length < 0) {
|
IRegion alternateRegion = null;
|
||||||
start = 0;
|
int start = element.getStartPos();
|
||||||
length = 0;
|
int length = element.getLength();
|
||||||
}
|
|
||||||
|
// Sanity check sometimes the parser may throw wrong numbers.
|
||||||
// 0 length and start and non-zero start line says we know
|
if (start < 0 || length < 0) {
|
||||||
// the line for some reason, but not the offset.
|
start = 0;
|
||||||
if (length == 0 && start == 0 && element.getStartLine() > 0) {
|
length = 0;
|
||||||
// We have the information in term of lines, we can work it out.
|
|
||||||
// Binary elements return the first executable statement so we have to substract -1
|
|
||||||
start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
|
|
||||||
if (element.getEndLine() > 0) {
|
|
||||||
length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
|
|
||||||
} else {
|
|
||||||
length = start;
|
|
||||||
}
|
}
|
||||||
// create an alternate region for the keyword highlight.
|
|
||||||
alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
|
// 0 length and start and non-zero start line says we know
|
||||||
if (start == length || length < 0) {
|
// the line for some reason, but not the offset.
|
||||||
if (alternateRegion != null) {
|
if (length == 0 && start == 0 && element.getStartLine() > 0) {
|
||||||
|
// We have the information in term of lines, we can work it out.
|
||||||
|
// Binary elements return the first executable statement so we have to subtract -1
|
||||||
|
start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
|
||||||
|
if (element.getEndLine() > 0) {
|
||||||
|
length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
|
||||||
|
} else {
|
||||||
|
length = start;
|
||||||
|
}
|
||||||
|
// create an alternate region for the keyword highlight.
|
||||||
|
alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
|
||||||
|
if (start == length || length < 0) {
|
||||||
|
if (alternateRegion != null) {
|
||||||
|
start = alternateRegion.getOffset();
|
||||||
|
length = alternateRegion.getLength();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setHighlightRange(start, length, moveCursor);
|
||||||
|
|
||||||
|
if (moveCursor) {
|
||||||
|
start = element.getIdStartPos();
|
||||||
|
length = element.getIdLength();
|
||||||
|
if (start == 0 && length == 0 && alternateRegion != null) {
|
||||||
start = alternateRegion.getOffset();
|
start = alternateRegion.getOffset();
|
||||||
length = alternateRegion.getLength();
|
length = alternateRegion.getLength();
|
||||||
}
|
}
|
||||||
|
if (start > -1 && length > 0) {
|
||||||
|
try {
|
||||||
|
textWidget.setRedraw(false);
|
||||||
|
sourceViewer.revealRange(start, length);
|
||||||
|
sourceViewer.setSelectedRange(start, length);
|
||||||
|
} finally {
|
||||||
|
textWidget.setRedraw(true);
|
||||||
|
}
|
||||||
|
markInNavigationHistory();
|
||||||
|
}
|
||||||
|
updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
|
||||||
}
|
}
|
||||||
|
} catch (IllegalArgumentException x) {
|
||||||
|
// No information to the user
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
// No information to the user
|
||||||
}
|
}
|
||||||
setHighlightRange(start, length, moveCursor);
|
} else if (moveCursor) {
|
||||||
|
|
||||||
if (moveCursor) {
|
|
||||||
start = element.getIdStartPos();
|
|
||||||
length = element.getIdLength();
|
|
||||||
if (start == 0 && length == 0 && alternateRegion != null) {
|
|
||||||
start = alternateRegion.getOffset();
|
|
||||||
length = alternateRegion.getLength();
|
|
||||||
}
|
|
||||||
if (start > -1 && getSourceViewer() != null) {
|
|
||||||
getSourceViewer().revealRange(start, length);
|
|
||||||
getSourceViewer().setSelectedRange(start, length);
|
|
||||||
}
|
|
||||||
updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} catch (IllegalArgumentException x) {
|
|
||||||
// No information to the user
|
|
||||||
} catch (BadLocationException e) {
|
|
||||||
// No information to the user
|
|
||||||
}
|
|
||||||
|
|
||||||
if (moveCursor)
|
|
||||||
resetHighlightRange();
|
resetHighlightRange();
|
||||||
|
markInNavigationHistory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2009 IBM Corporation and others.
|
* Copyright (c) 2005, 2011 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
* QNX Software System
|
* QNX Software System
|
||||||
|
* Wind River Systems
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.ui.editor.asm;
|
package org.eclipse.cdt.internal.ui.editor.asm;
|
||||||
|
|
||||||
|
@ -462,66 +463,92 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
|
||||||
* @param moveCursor if true the editor is scrolled to show the range.
|
* @param moveCursor if true the editor is scrolled to show the range.
|
||||||
*/
|
*/
|
||||||
public void setSelection(ISourceRange element, boolean moveCursor) {
|
public void setSelection(ISourceRange element, boolean moveCursor) {
|
||||||
|
if (getSelectionProvider() == null)
|
||||||
if (element == null) {
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
ISelection selection= getSelectionProvider().getSelection();
|
||||||
|
if (selection instanceof ITextSelection) {
|
||||||
|
ITextSelection textSelection= (ITextSelection) selection;
|
||||||
|
// PR 39995: [navigation] Forward history cleared after going back in navigation history:
|
||||||
|
// mark only in navigation history if the cursor is being moved (which it isn't if
|
||||||
|
// this is called from a PostSelectionEvent that should only update the magnet)
|
||||||
|
if (moveCursor && (textSelection.getOffset() != 0 || textSelection.getLength() != 0))
|
||||||
|
markInNavigationHistory();
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (element != null) {
|
||||||
IRegion alternateRegion = null;
|
|
||||||
int start = element.getStartPos();
|
StyledText textWidget= null;
|
||||||
int length = element.getLength();
|
|
||||||
|
ISourceViewer sourceViewer= getSourceViewer();
|
||||||
|
if (sourceViewer == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
textWidget= sourceViewer.getTextWidget();
|
||||||
|
if (textWidget == null)
|
||||||
|
return;
|
||||||
|
|
||||||
// Sanity check sometimes the parser may throw wrong numbers.
|
try {
|
||||||
if (start < 0 || length < 0) {
|
IRegion alternateRegion = null;
|
||||||
start = 0;
|
int start = element.getStartPos();
|
||||||
length = 0;
|
int length = element.getLength();
|
||||||
}
|
|
||||||
|
// Sanity check sometimes the parser may throw wrong numbers.
|
||||||
// 0 length and start and non-zero start line says we know
|
if (start < 0 || length < 0) {
|
||||||
// the line for some reason, but not the offset.
|
start = 0;
|
||||||
if (length == 0 && start == 0 && element.getStartLine() > 0) {
|
length = 0;
|
||||||
// We have the information in term of lines, we can work it out.
|
|
||||||
// Binary elements return the first executable statement so we have to substract -1
|
|
||||||
start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
|
|
||||||
if (element.getEndLine() > 0) {
|
|
||||||
length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
|
|
||||||
} else {
|
|
||||||
length = start;
|
|
||||||
}
|
}
|
||||||
// create an alternate region for the keyword highlight.
|
|
||||||
alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
|
// 0 length and start and non-zero start line says we know
|
||||||
if (start == length || length < 0) {
|
// the line for some reason, but not the offset.
|
||||||
if (alternateRegion != null) {
|
if (length == 0 && start == 0 && element.getStartLine() > 0) {
|
||||||
|
// We have the information in term of lines, we can work it out.
|
||||||
|
// Binary elements return the first executable statement so we have to subtract -1
|
||||||
|
start = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getStartLine() - 1);
|
||||||
|
if (element.getEndLine() > 0) {
|
||||||
|
length = getDocumentProvider().getDocument(getEditorInput()).getLineOffset(element.getEndLine()) - start;
|
||||||
|
} else {
|
||||||
|
length = start;
|
||||||
|
}
|
||||||
|
// create an alternate region for the keyword highlight.
|
||||||
|
alternateRegion = getDocumentProvider().getDocument(getEditorInput()).getLineInformation(element.getStartLine() - 1);
|
||||||
|
if (start == length || length < 0) {
|
||||||
|
if (alternateRegion != null) {
|
||||||
|
start = alternateRegion.getOffset();
|
||||||
|
length = alternateRegion.getLength();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setHighlightRange(start, length, moveCursor);
|
||||||
|
|
||||||
|
if (moveCursor) {
|
||||||
|
start = element.getIdStartPos();
|
||||||
|
length = element.getIdLength();
|
||||||
|
if (start == 0 && length == 0 && alternateRegion != null) {
|
||||||
start = alternateRegion.getOffset();
|
start = alternateRegion.getOffset();
|
||||||
length = alternateRegion.getLength();
|
length = alternateRegion.getLength();
|
||||||
}
|
}
|
||||||
|
if (start > -1 && length > 0) {
|
||||||
|
try {
|
||||||
|
textWidget.setRedraw(false);
|
||||||
|
sourceViewer.revealRange(start, length);
|
||||||
|
sourceViewer.setSelectedRange(start, length);
|
||||||
|
} finally {
|
||||||
|
textWidget.setRedraw(true);
|
||||||
|
}
|
||||||
|
markInNavigationHistory();
|
||||||
|
}
|
||||||
|
updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
|
||||||
}
|
}
|
||||||
|
} catch (IllegalArgumentException x) {
|
||||||
|
// No information to the user
|
||||||
|
} catch (BadLocationException e) {
|
||||||
|
// No information to the user
|
||||||
}
|
}
|
||||||
setHighlightRange(start, length, moveCursor);
|
} else if (moveCursor) {
|
||||||
|
|
||||||
if (moveCursor) {
|
|
||||||
start = element.getIdStartPos();
|
|
||||||
length = element.getIdLength();
|
|
||||||
if (start == 0 && length == 0 && alternateRegion != null) {
|
|
||||||
start = alternateRegion.getOffset();
|
|
||||||
length = alternateRegion.getLength();
|
|
||||||
}
|
|
||||||
if (start > -1 && getSourceViewer() != null) {
|
|
||||||
getSourceViewer().revealRange(start, length);
|
|
||||||
getSourceViewer().setSelectedRange(start, length);
|
|
||||||
}
|
|
||||||
updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
} catch (IllegalArgumentException x) {
|
|
||||||
// No information to the user
|
|
||||||
} catch (BadLocationException e) {
|
|
||||||
// No information to the user
|
|
||||||
}
|
|
||||||
|
|
||||||
if (moveCursor)
|
|
||||||
resetHighlightRange();
|
resetHighlightRange();
|
||||||
|
markInNavigationHistory();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue