Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public static ImageDescriptor getUndoImageDescriptor() {
public void run() {
StyledText tw = tv.getTextWidget();
List<UnifiedDiff> diffs1 = get(tv);
if (diffs1 == null) {
return;
}
List<Position> positions = new ArrayList<>();
List<String> replaceStrings = new ArrayList<>();
for (UnifiedDiff diff : diffs1) {
Expand All @@ -84,6 +87,9 @@ public void run() {
ext.updateCodeMinings();
}
disposeUnifiedDiff(tv, model, tv.getTextWidget());
if (positions.isEmpty()) {
return;
}
// we have to insert with delay because otherwise the line header code minings
// cannot be deleted
runAfterRepaintFinished(tw, () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ public void run() {
removeAnnotationModelListener(model, tv.getTextWidget());
}
List<UnifiedDiff> diffs1 = get(tv);
if (diffs1 == null) {
return;
}
for (UnifiedDiff diff : diffs1) {
List<Annotation> annos = getAllAnnotationsForUnifiedDiff(model, diff);
for (var lanno : annos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ public String getLabel() {
@Override
public void run() {
List<UnifiedDiff> diffs1 = get(tv);
if (diffs1 == null) {
return;
}
for (UnifiedDiff diff : diffs1) {
List<Annotation> annos = getAllAnnotationsForUnifiedDiff(model, diff);
for (var lanno : annos) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public void run() {
}
int offset = sel.getOffset();
List<UnifiedDiff> diffs1 = get(tv);
if (diffs1 == null || diffs1.size() == 0) {
return;
}
// get next UnifiedDiff for given offset
UnifiedDiff nextDiff = null;
for (UnifiedDiff diff : diffs1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public void run() {
}
int offset = sel.getOffset();
List<UnifiedDiff> diffs1 = get(tv);
if (diffs1 == null || diffs1.size() == 0) {
return;
}
// get next UnifiedDiff for given offset
UnifiedDiff nextDiff = null;
for (UnifiedDiff diff : diffs1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ public String getLabel() {
public void run() {
var tw = tv.getTextWidget();
List<UnifiedDiff> diffs1 = get(tv);
if (diffs1 == null) {
return;
}
List<Position> positions = new ArrayList<>();
List<String> replaceStrings = new ArrayList<>();
for (UnifiedDiff diff : diffs1) {
Expand All @@ -72,6 +75,9 @@ public void run() {
ext.updateCodeMinings();
}
disposeUnifiedDiff(tv, model, tv.getTextWidget());
if (positions.isEmpty()) {
return;
}
// we have to insert with delay because otherwise the line header code minings
// cannot be deleted
runAfterRepaintFinished(tw, () -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,15 @@ public UnifiedDiff getUnifiedDiff() {

@Override
public void dispose() {
cleanCachedData();
super.dispose();
}

private void cleanCachedData() {
foregrounds = null;
backgrounds = null;
lastRectangle = null;
cachedFont = null;
clearStyledFonts();
}

Expand All @@ -634,14 +642,13 @@ public Point draw(GC gc, StyledText textWidget, Color color, int x, int y) {
gc.setForeground(c);
Font font = textWidget.getFont();
gc.setFont(font);
if (cachedFont != null && !cachedFont.equals(font)) {
if (cachedFont != null && (cachedFont.isDisposed() || !cachedFont.equals(font))) {
// font might have been changed in the meantime - remove cache
lastRectangle = null;
backgrounds = null;
foregrounds = null;
clearStyledFonts();
cleanCachedData();
}
cachedFont = font;
if (lastRectangle != null && backgrounds != null && foregrounds != null) {
boolean fontIsDisposed = false;
// draw background
// vs code is drawing the background to the top right of the editor - we do here
// the same!
Expand All @@ -663,20 +670,26 @@ public Point draw(GC gc, StyledText textWidget, Color color, int x, int y) {
}
if (f.font == null) {
gc.setFont(cachedFont);
} else {
} else if (!f.font.isDisposed()) {
gc.setFont(f.font);
} else {
cleanCachedData();
cachedFont = font;
fontIsDisposed = true;
break;
}
gc.setBackground(f.background);
gc.setForeground(f.foreground);
gc.drawString(f.str, x + f.x, y + f.y, true);
}
lastRectangle = new Rectangle(x, y, lastRectangle.width, lastRectangle.height);
return new Point(lastRectangle.width, lastRectangle.height);
if (!fontIsDisposed) {
lastRectangle = new Rectangle(x, y, lastRectangle.width, lastRectangle.height);
return new Point(lastRectangle.width, lastRectangle.height);
}
}
// first run to get width and height for label
Point result = super.draw(gc, textWidget, color, x, y);
lastRectangle = new Rectangle(x, y, result.x, result.y);
cachedFont = font;

// draw background
// vs code is drawing the background to the top right of the editor - we do here
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,8 @@ private static void drawToolBarForAllDiffs(ITextViewer tv, IAnnotationModel mode
UnifiedDiffMode mode) {
StyledText tw = tv.getTextWidget();
var tm = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
List<UnifiedDiff> diffs = get(tv);
if (UnifiedDiffMode.OVERLAY_MODE.equals(mode) || UnifiedDiffMode.OVERLAY_READ_ONLY_MODE.equals(mode)) {
List<UnifiedDiff> diffs = get(tv);
if (!isReadOnly(diffs)) {
var acceptAll = new AcceptAllRunnable(tv, model);
addToolbarAction(tm, acceptAll.getLabel(), AcceptAllRunnable.getImageDescriptor(), acceptAll);
Expand Down
Loading