Commit a1c3641f authored by Alexander Doroshko's avatar Alexander Doroshko
Browse files

EA-137940 - ISE: OffsetMap.getOffset

parent 25bf3dc0
Branches unavailable Tags unavailable
No related merge requests found
Showing with 2 additions and 1 deletion
+2 -1
......@@ -59,6 +59,7 @@ public class XmlTagInsertHandler implements InsertHandler<LookupElement> {
public void handleInsert(@NotNull InsertionContext context, @NotNull LookupElement item) {
Project project = context.getProject();
Editor editor = context.getEditor();
int startOffset = context.getStartOffset();
Document document = InjectedLanguageUtil.getTopLevelEditor(editor).getDocument();
Ref<PsiElement> currentElementRef = Ref.create();
// Need to insert " " to prevent creating tags like <tagThis is my text
......@@ -66,7 +67,7 @@ public class XmlTagInsertHandler implements InsertHandler<LookupElement> {
final int offset = editor.getCaretModel().getOffset();
editor.getDocument().insertString(offset, " ");
PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
currentElementRef.set(context.getFile().findElementAt(context.getStartOffset()));
currentElementRef.set(context.getFile().findElementAt(startOffset));
editor.getDocument().deleteString(offset, offset + 1);
});
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment