diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java index 2fb67a7e165e..31a395056060 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/CustomTemplateCallback.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2016 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.template; import com.intellij.codeInsight.template.impl.TemplateImpl; @@ -58,12 +44,13 @@ public class CustomTemplateCallback { myProject = file.getProject(); myTemplateManager = TemplateManager.getInstance(myProject); - myOffset = getOffset(editor); - PsiElement element = InjectedLanguageManager.getInstance(file.getProject()).findInjectedElementAt(file, myOffset); + int parentEditorOffset = getOffset(editor); + PsiElement element = InjectedLanguageManager.getInstance(file.getProject()).findInjectedElementAt(file, parentEditorOffset); myFile = element != null ? element.getContainingFile() : file; myInInjectedFragment = InjectedLanguageManager.getInstance(myProject).isInjectedFragment(myFile); - myEditor = myInInjectedFragment ? InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file, myOffset) : editor; + myEditor = myInInjectedFragment ? InjectedLanguageUtil.getEditorForInjectedLanguageNoCommit(editor, file, parentEditorOffset) : editor; + myOffset = myInInjectedFragment ? getOffset(myEditor) : parentEditorOffset; } public TemplateManager getTemplateManager() { diff --git a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java index 7c26ecca7bcb..75efd5fb6f0f 100644 --- a/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java +++ b/xml/impl/src/com/intellij/codeInsight/template/emmet/ZenCodingTemplate.java @@ -1,18 +1,4 @@ -/* - * Copyright 2000-2017 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ +// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.codeInsight.template.emmet; import com.intellij.application.options.emmet.EmmetOptions; @@ -82,7 +68,7 @@ public class ZenCodingTemplate extends CustomLiveTemplateBase { return null; } for (ZenCodingGenerator generator : ZenCodingGenerator.getInstances()) { - if (generator.isMyContext(callback, wrapping) && generator.isAppliedByDefault(callback.getContext())) { + if (generator.isMyContext(callback, wrapping) && generator.isAppliedByDefault(context)) { return generator; } }