live templates inside file templates: ensure caret at the 0 position as state could...
authorAnna.Kozlova <anna.kozlova@jetbrains.com>
Thu, 17 Nov 2016 12:59:20 +0000 (13:59 +0100)
committerAnna.Kozlova <anna.kozlova@jetbrains.com>
Thu, 17 Nov 2016 13:29:36 +0000 (14:29 +0100)
platform/lang-impl/src/com/intellij/ide/fileTemplates/actions/CreateFromTemplateActionBase.java

index 789f1a42527097072185a54bb1d580ff187471d9..a6b1a60fb198a221ffc4ca1f34d0d747acb2da18 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * 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.
@@ -100,6 +100,8 @@ public abstract class CreateFromTemplateActionBase extends AnAction {
       template.addVariable(variable, null, "\"" + variable + "\"", true);
     }
     WriteCommandAction.runWriteCommandAction(project, () -> editor.getDocument().setText(template.getTemplateText()));
+    //ensure caret at the start of the template
+    editor.getCaretModel().moveToOffset(0);
     TemplateManager.getInstance(project).startTemplate(editor, template);
   }