improve notification about forced soft wraps

don't show notification if soft wraps were enabled, but no actual soft
wraps exist currently
This commit is contained in:
Dmitry Batrak
2017-06-22 14:14:57 +03:00
parent 201d32ac9c
commit d597c9dfcf
3 changed files with 20 additions and 3 deletions
@@ -142,7 +142,8 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
public static final Object IGNORE_MOUSE_TRACKING = "ignore_mouse_tracking";
private static final Key<JComponent> PERMANENT_HEADER = Key.create("PERMANENT_HEADER");
public static final Key<Boolean> DO_DOCUMENT_UPDATE_TEST = Key.create("DoDocumentUpdateTest");
static final Key<Boolean> FORCED_SOFT_WRAPS = Key.create("forced.soft.wraps");
public static final Key<Boolean> FORCED_SOFT_WRAPS = Key.create("forced.soft.wraps");
public static final Key<Boolean> SOFT_WRAPS_EXIST = Key.create("soft.wraps.exist");
public static final Key<Boolean> DISABLE_CARET_POSITION_KEEPING = Key.create("editor.disable.caret.position.keeping");
static final Key<Boolean> DISABLE_CARET_SHIFT_ON_WHITESPACE_INSERTION = Key.create("editor.disable.caret.shift.on.whitespace.insertion");
private static final boolean HONOR_CAMEL_HUMPS_ON_TRIPLE_CLICK = Boolean.parseBoolean(System.getProperty("idea.honor.camel.humps.on.triple.click"));
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -46,7 +46,8 @@ public class ForcedSoftWrapsNotificationProvider extends EditorNotifications.Pro
final Editor editor = ((TextEditor)fileEditor).getEditor();
final Project project = editor.getProject();
if (project == null
|| !Boolean.TRUE.equals(editor.getUserData(EditorImpl.FORCED_SOFT_WRAPS))
|| !Boolean.TRUE.equals(editor.getUserData(EditorImpl.FORCED_SOFT_WRAPS))
|| !Boolean.TRUE.equals(editor.getUserData(EditorImpl.SOFT_WRAPS_EXIST))
|| PropertiesComponent.getInstance().isTrueValue(DISABLED_NOTIFICATION_KEY)) return null;
final EditorNotificationPanel panel = new EditorNotificationPanel();
@@ -31,8 +31,11 @@ import com.intellij.openapi.editor.impl.softwrap.SoftWrapPainter;
import com.intellij.openapi.editor.impl.softwrap.SoftWrapsStorage;
import com.intellij.openapi.editor.impl.view.IterationState;
import com.intellij.openapi.editor.markup.TextAttributes;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Segment;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.ui.EditorNotifications;
import com.intellij.util.DocumentUtil;
import org.intellij.lang.annotations.JdkConstants;
import org.jetbrains.annotations.NotNull;
@@ -250,6 +253,18 @@ public class SoftWrapApplianceManager implements Dumpable {
finally {
myInProgress = false;
}
Project project = myEditor.getProject();
VirtualFile file = myEditor.getVirtualFile();
if (project != null && file != null && myEditor.getUserData(EditorImpl.FORCED_SOFT_WRAPS) != null) {
if (myStorage.isEmpty()) {
myEditor.putUserData(EditorImpl.SOFT_WRAPS_EXIST, null);
}
else {
myEditor.putUserData(EditorImpl.SOFT_WRAPS_EXIST, Boolean.TRUE);
EditorNotifications.getInstance(project).updateNotifications(file);
}
}
}
private void doRecalculateSoftWraps(IncrementalCacheUpdateEvent event, int endOffsetUpperEstimate) {