|
39 | 39 | import org.eclipse.jface.preference.IPreferenceStore; |
40 | 40 | import org.eclipse.jface.text.BadLocationException; |
41 | 41 | import org.eclipse.jface.text.IDocument; |
| 42 | +import org.eclipse.jface.text.IRegion; |
42 | 43 | import org.eclipse.jface.text.ITextViewer; |
43 | 44 | import org.eclipse.jface.text.Position; |
44 | 45 | import org.eclipse.jface.text.TextSelection; |
|
55 | 56 | import org.eclipse.lsp4j.MarkupKind; |
56 | 57 | import org.eclipse.lsp4j.Range; |
57 | 58 | import org.eclipse.lsp4j.jsonrpc.messages.Either; |
| 59 | +import org.eclipse.swt.custom.StyledText; |
58 | 60 | import org.eclipse.swt.widgets.Display; |
59 | 61 | import org.eclipse.ui.IEditorPart; |
60 | 62 | import org.eclipse.ui.IEditorReference; |
@@ -246,6 +248,27 @@ private static void updateHighlightAnnotations(IEditorPart editor, ISourceViewer |
246 | 248 | } else { |
247 | 249 | ((ISourceViewerExtension5) sourceViewer).updateCodeMinings(); |
248 | 250 | } |
| 251 | + |
| 252 | + /* |
| 253 | + * Hack for Big Sur CodeMining layout issues when toggle CodeMinings on/off |
| 254 | + * After 100ms emulate resize editor visible region |
| 255 | + */ |
| 256 | + final StyledText textWidget = sourceViewer.getTextWidget(); |
| 257 | + if (textWidget != null && !textWidget.isDisposed()) { |
| 258 | + textWidget.getDisplay().timerExec(100, () -> { |
| 259 | + if (!textWidget.isDisposed()) { |
| 260 | + IRegion visibleRegion = sourceViewer.getVisibleRegion(); |
| 261 | + int offset = visibleRegion.getOffset(); |
| 262 | + int length = visibleRegion.getLength(); |
| 263 | + if (length > 1) { |
| 264 | + sourceViewer.setVisibleRegion(offset, length - 1); |
| 265 | + sourceViewer.setVisibleRegion(offset, length); |
| 266 | + } else { |
| 267 | + sourceViewer.resetVisibleRegion(); |
| 268 | + } |
| 269 | + } |
| 270 | + }); |
| 271 | + } |
249 | 272 | } |
250 | 273 | } |
251 | 274 |
|
|
0 commit comments