IDEA-127761 diff: force soft wraps for files with long lines

This check was ignored if soft wraps were enabled in IDE, but disabled in diff viewer
This commit is contained in:
Aleksey Pivovarov
2016-03-24 19:45:34 +03:00
parent 94df39efdb
commit 6a70531384
2 changed files with 8 additions and 7 deletions
@@ -129,8 +129,10 @@ public class SetEditorSettingsAction extends ActionGroup implements DumbAware {
@Override
public void applyDefaults(@NotNull List<? extends Editor> editors) {
for (Editor editor : editors) {
if (editor.getUserData(EditorImpl.FORCED_SOFT_WRAPS) != null) myForcedSoftWrap = true;
if (!myTextSettings.isUseSoftWraps()) {
for (Editor editor : editors) {
myForcedSoftWrap = myForcedSoftWrap || ((EditorImpl)editor).shouldSoftWrapsBeForced();
}
}
super.applyDefaults(editors);
}
@@ -344,7 +344,7 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
initTabPainter();
myIsViewer = viewer;
mySettings = new SettingsImpl(this, project);
if (shouldSoftWrapsBeForced()) {
if (!mySettings.isUseSoftWraps() && shouldSoftWrapsBeForced()) {
mySettings.setUseSoftWrapsQuiet();
putUserData(FORCED_SOFT_WRAPS, Boolean.TRUE);
}
@@ -583,10 +583,9 @@ public final class EditorImpl extends UserDataHolderBase implements EditorEx, Hi
updateCaretCursor();
}
private boolean shouldSoftWrapsBeForced() {
if (mySettings.isUseSoftWraps() ||
// Disable checking for files in intermediate states - e.g. for files during refactoring.
myProject != null && PsiDocumentManager.getInstance(myProject).isDocumentBlockedByPsi(myDocument)) {
public boolean shouldSoftWrapsBeForced() {
if (myProject != null && PsiDocumentManager.getInstance(myProject).isDocumentBlockedByPsi(myDocument)) {
// Disable checking for files in intermediate states - e.g. for files during refactoring.
return false;
}
int lineWidthLimit = Registry.intValue("editor.soft.wrap.force.limit");