Emmet: fixed preview in injections (WEB-29360)

This commit is contained in:
Alexander Zolotov
2018-07-19 18:41:51 +03:00
parent 862b62df42
commit 260e08074d
2 changed files with 7 additions and 34 deletions
@@ -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() {
@@ -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;
}
}