mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-06 03:21:12 +07:00
Ensure read only status when failing to change document text
GitOrigin-RevId: dccc9f59b04fcfa463c724ec348ad1a996de769c
This commit is contained in:
committed by
intellij-monorepo-bot
parent
4a821f078d
commit
c3562acee9
@@ -124,8 +124,11 @@ public final class DocumentFragmentContent extends DiffContentBase implements Do
|
||||
protected void onDocumentChanged1(@NotNull DocumentEvent event) {
|
||||
if (!myRangeMarker.isValid()) {
|
||||
myDocument2.setReadOnly(false);
|
||||
replaceString(myDocument2, 0, myDocument2.getTextLength(), DiffBundle.message("synchronize.document.and.its.fragment.range.error"));
|
||||
myDocument2.setReadOnly(true);
|
||||
try {
|
||||
replaceString(myDocument2, 0, myDocument2.getTextLength(), DiffBundle.message("synchronize.document.and.its.fragment.range.error"));
|
||||
} finally {
|
||||
myDocument2.setReadOnly(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
CharSequence newText = myDocument1.getCharsSequence().subSequence(myRangeMarker.getStartOffset(), myRangeMarker.getEndOffset());
|
||||
@@ -156,8 +159,11 @@ public final class DocumentFragmentContent extends DiffContentBase implements Do
|
||||
}
|
||||
else {
|
||||
myDocument2.setReadOnly(false);
|
||||
myDocument2.setText(DiffBundle.message("synchronize.document.and.its.fragment.range.error"));
|
||||
myDocument2.setReadOnly(true);
|
||||
try {
|
||||
myDocument2.setText(DiffBundle.message("synchronize.document.and.its.fragment.range.error"));
|
||||
} finally {
|
||||
myDocument2.setReadOnly(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -460,9 +460,11 @@ public final class ImplementationViewComponent extends JPanel {
|
||||
DocumentUtil.writeInRunUndoTransparentAction(() -> {
|
||||
Document fragmentDoc = myEditor.getDocument();
|
||||
fragmentDoc.setReadOnly(false);
|
||||
|
||||
fragmentDoc.replaceString(0, fragmentDoc.getTextLength(), newText);
|
||||
fragmentDoc.setReadOnly(true);
|
||||
try {
|
||||
fragmentDoc.replaceString(0, fragmentDoc.getTextLength(), newText);
|
||||
} finally {
|
||||
fragmentDoc.setReadOnly(true);
|
||||
}
|
||||
|
||||
PsiElement element = elt.getElementForShowUsages();
|
||||
PsiFile file = element == null ? null : element.getContainingFile();
|
||||
|
||||
@@ -119,8 +119,12 @@ public class ByteCodeViewerComponent extends JPanel implements Disposable {
|
||||
DocumentUtil.writeInRunUndoTransparentAction(() -> {
|
||||
Document fragmentDoc = myEditor.getDocument();
|
||||
fragmentDoc.setReadOnly(false);
|
||||
fragmentDoc.replaceString(0, fragmentDoc.getTextLength(), bytecode);
|
||||
fragmentDoc.setReadOnly(true);
|
||||
try {
|
||||
fragmentDoc.replaceString(0, fragmentDoc.getTextLength(), bytecode);
|
||||
} finally {
|
||||
fragmentDoc.setReadOnly(true);
|
||||
}
|
||||
|
||||
myEditor.getCaretModel().moveToOffset(offset);
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
|
||||
});
|
||||
|
||||
@@ -181,10 +181,13 @@ class PsiViewerDebugPanel(
|
||||
DebuggerUIUtil.invokeLater {
|
||||
expressionRange = psiRangeInFile
|
||||
editor.document.setReadOnly(false)
|
||||
runWriteAction {
|
||||
editor.document.setText(fileText)
|
||||
try {
|
||||
runWriteAction {
|
||||
editor.document.setText(fileText)
|
||||
}
|
||||
} finally {
|
||||
editor.document.setReadOnly(true)
|
||||
}
|
||||
editor.document.setReadOnly(true)
|
||||
editor.selectAndScroll(psiRangeInFile)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user