mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 13:02:30 +07:00
PY-25106 Do not change cell source if it's empty and new source is also empty
This commit is contained in:
@@ -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 : "")));
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user