mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
Fix NPE when opening an editor in segmented mode
This commit is contained in:
parent
bf4290500d
commit
e82ae65f18
2 changed files with 8 additions and 30 deletions
|
@ -41,6 +41,8 @@ import org.eclipse.swt.widgets.Display;
|
||||||
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
|
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
|
||||||
import org.eclipse.ui.texteditor.AbstractTextEditor;
|
import org.eclipse.ui.texteditor.AbstractTextEditor;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.ui.PreferenceConstants;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
|
import org.eclipse.cdt.internal.ui.text.CSourceViewerConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -157,6 +159,8 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
||||||
if (fPreferenceStore != null) {
|
if (fPreferenceStore != null) {
|
||||||
fPreferenceStore.addPropertyChangeListener(this);
|
fPreferenceStore.addPropertyChangeListener(this);
|
||||||
initializeViewerColors();
|
initializeViewerColors();
|
||||||
|
// init flag here in case we start in segmented mode
|
||||||
|
fWasProjectionMode= fPreferenceStore.getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
fIsConfigured= true;
|
fIsConfigured= true;
|
||||||
|
|
|
@ -125,8 +125,10 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
try {
|
try {
|
||||||
FoldingStructureComputationContext ctx= createContext(fInitialReconcilePending);
|
FoldingStructureComputationContext ctx= createContext(fInitialReconcilePending);
|
||||||
fInitialReconcilePending= false;
|
fInitialReconcilePending= false;
|
||||||
|
if (ctx != null) {
|
||||||
ctx.fAST= ast;
|
ctx.fAST= ast;
|
||||||
update(ctx);
|
update(ctx);
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
fReconciling= false;
|
fReconciling= false;
|
||||||
}
|
}
|
||||||
|
@ -380,7 +382,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
|
|
||||||
IRegion preRegion;
|
IRegion preRegion;
|
||||||
if (firstLine < captionLine) {
|
if (firstLine < captionLine) {
|
||||||
// preRegion= new Region(offset + prefixEnd, contentStart - prefixEnd);
|
|
||||||
int preOffset= document.getLineOffset(firstLine);
|
int preOffset= document.getLineOffset(firstLine);
|
||||||
IRegion preEndLineInfo= document.getLineInformation(captionLine);
|
IRegion preEndLineInfo= document.getLineInformation(captionLine);
|
||||||
int preEnd= preEndLineInfo.getOffset();
|
int preEnd= preEndLineInfo.getOffset();
|
||||||
|
@ -422,33 +423,6 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * Finds the offset of the first identifier part within <code>content</code>.
|
|
||||||
// * Returns 0 if none is found.
|
|
||||||
// *
|
|
||||||
// * @param content the content to search
|
|
||||||
// * @return the first index of a unicode identifier part, or zero if none can
|
|
||||||
// * be found
|
|
||||||
// */
|
|
||||||
// private int findPrefixEnd(final CharSequence content) {
|
|
||||||
// // return the index after the leading '/*' or '/**'
|
|
||||||
// int len= content.length();
|
|
||||||
// int i= 0;
|
|
||||||
// while (i < len && isWhiteSpace(content.charAt(i)))
|
|
||||||
// i++;
|
|
||||||
// if (len >= i + 2 && content.charAt(i) == '/' && content.charAt(i + 1) == '*')
|
|
||||||
// if (len >= i + 3 && content.charAt(i + 2) == '*')
|
|
||||||
// return i + 3;
|
|
||||||
// else
|
|
||||||
// return i + 2;
|
|
||||||
// else
|
|
||||||
// return i;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// private boolean isWhiteSpace(char c) {
|
|
||||||
// return c == ' ' || c == '\t';
|
|
||||||
// }
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeCaptionOffset(org.eclipse.jface.text.IDocument)
|
* @see org.eclipse.jface.text.source.projection.IProjectionPosition#computeCaptionOffset(org.eclipse.jface.text.IDocument)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue