Attached is a replacement patch which I believe fixes the issue with the region selection direction and with indentation potentially being incorrectly applied to text that is inserted by the template. Previously when text was being inserted at the region start it was actually going into region, which means that it will have been possible for template contents to have accidentally been indented along with the region that the user selected. I've changed the marker insertion type for the start boundary, which should preserve the original indentation of text which was inserted by the template, i.e. if text inserted by the template should be indented this is now back under control of the template rather than applied by accident. The changes do mean that the indentation of existing templates may change, but I think this will only be for templates which accidentally omitted the indentation directives because indentation was mistakenly applied as part of the region.