mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-26131 Commit the document before accessing PSI in PyMethodNameTypedHandler
otherwise we might end up accessing stale PSI tree where there is "got_message" instead of "info" under the caret.
This commit is contained in:
@@ -50,6 +50,7 @@ public class PyMethodNameTypedHandler extends TypedHandlerDelegate {
|
||||
final Document document = editor.getDocument();
|
||||
final PsiDocumentManager documentManager = PsiDocumentManager.getInstance(project);
|
||||
final int offset = editor.getCaretModel().getOffset();
|
||||
documentManager.commitDocument(document);
|
||||
|
||||
PsiElement token = file.findElementAt(offset - 1);
|
||||
if (token == null) return Result.CONTINUE; // sanity check: beyond EOL
|
||||
@@ -76,7 +77,6 @@ public class PyMethodNameTypedHandler extends TypedHandlerDelegate {
|
||||
pname = "cls";
|
||||
}
|
||||
else if (flags.isStaticMethod()) pname = "";
|
||||
documentManager.commitDocument(document);
|
||||
// TODO: only print the ")" if Settings require it
|
||||
int caretOffset = editor.getCaretModel().getOffset();
|
||||
String textToType = "(" + pname + ")";
|
||||
|
||||
Reference in New Issue
Block a user