PY-25106 Do not change cell source if it's empty and new source is also empty

This commit is contained in:
Valentina Kiryushkina
2017-07-19 19:26:17 +03:00
parent 764a8e20e3
commit b4aea66bc3
2 changed files with 9 additions and 1 deletions

View File

@@ -275,6 +275,9 @@ public abstract class IpnbEditablePanel<T extends JComponent, K extends IpnbEdit
public void updateCellSource() {
final String text = myEditableTextArea.getText();
if (StringUtil.isEmpty(text) && myCell.getSource().isEmpty()) {
return;
}
myCell.setSource(Arrays.asList(StringUtil.splitByLinesKeepSeparators(text != null ? text : "")));
}

View File

@@ -289,6 +289,9 @@ public class IpnbCodePanel extends IpnbEditablePanel<JComponent, IpnbCodeCell> {
public void updateCellSource() {
final Document document = myCodeSourcePanel.getEditor().getDocument();
final String text = document.getText();
if (StringUtil.isEmpty(text) && myCell.getSource().isEmpty()) {
return;
}
myCell.setSource(Arrays.asList(StringUtil.splitByLinesKeepSeparators(text)));
}
@@ -334,7 +337,9 @@ public class IpnbCodePanel extends IpnbEditablePanel<JComponent, IpnbCodeCell> {
}
if (replacementContent != null) {
myCell.setSource(Arrays.asList(StringUtil.splitByLinesKeepSeparators(replacementContent)));
if (replacementContent.isEmpty() || myCell.getSource().isEmpty()) {
myCell.setSource(Arrays.asList(StringUtil.splitByLinesKeepSeparators(replacementContent)));
}
String prompt = IpnbEditorUtil.prompt(null, IpnbEditorUtil.PromptType.In);
myCell.setPromptNumber(null);
myPromptLabel.setText(prompt);