From 566dc53c92a0af6f157fccf4b53447c62b78c2da Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 3 Aug 2015 11:38:08 -0700 Subject: [PATCH] Use the formatter line length for margin. There is a similar change in JDT: https://git.eclipse.org/c/jdt/eclipse.jdt.ui.git/commit/?id=6d5249a7460d4eadb7933705626efb5fbb168d42 --- .../org/eclipse/cdt/internal/ui/editor/CEditor.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index ffa6f353a0b..53c0e9c0ddb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -314,7 +314,7 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi } } - class AdaptedSourceViewer extends CSourceViewer { + class AdaptedSourceViewer extends CSourceViewer { public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles, IPreferenceStore store) { @@ -2536,10 +2536,18 @@ public class CEditor extends TextEditor implements ICEditor, ISelectionChangedLi @Override protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) { super.configureSourceViewerDecorationSupport(support); - //Enhance the stock source viewer decorator with a bracket matcher + // Enhance the stock source viewer decorator with a bracket matcher support.setCharacterPairMatcher(fBracketMatcher); support.setMatchingCharacterPainterPreferenceKeys(MATCHING_BRACKETS, MATCHING_BRACKETS_COLOR); ((CSourceViewerDecorationSupport) support).setInactiveCodePainterPreferenceKeys(INACTIVE_CODE_ENABLE, INACTIVE_CODE_COLOR); + + // The base class will have already called setMarginPainterPreferenceKeys. We override it + // here with more specific values for the C/C++ editor. Note that this needs to go after + // the call to super since the last invocation wins. + support.setMarginPainterPreferenceKeys( + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, + AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, + DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT); } /**