From c52ccad14b3736b2975835351cdba31e9f7c6ea1 Mon Sep 17 00:00:00 2001 From: Dmitry Maluka Date: Tue, 20 Oct 2020 23:46:55 +0200 Subject: [PATCH] hltrailingws: adjust autoclose plugin implementation Fix unwanted highlighting of whitespace in the new line when inserting a newline after a bracket (when hltrailingws is on). To fix it, change the order of operations: insert the new empty line after all other things, to avoid moving the cursor between lines after that. --- runtime/plugins/autoclose/autoclose.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/plugins/autoclose/autoclose.lua b/runtime/plugins/autoclose/autoclose.lua index 531b7601..f1fc2fad 100644 --- a/runtime/plugins/autoclose/autoclose.lua +++ b/runtime/plugins/autoclose/autoclose.lua @@ -50,11 +50,11 @@ function preInsertNewline(bp) for i = 1, #autoNewlinePairs do if curRune == charAt(autoNewlinePairs[i], 1) then if nextRune == charAt(autoNewlinePairs[i], 2) then - bp:InsertNewline() - bp:InsertTab() bp.Buf:Insert(-bp.Cursor.Loc, "\n" .. ws) bp:StartOfLine() bp:CursorLeft() + bp:InsertNewline() + bp:InsertTab() return false end end