From 1dbe571cfe8b003f539f09385d7b719f7f13b381 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 6 Aug 2024 21:09:01 +0800 Subject: =?UTF-8?q?=E5=BA=94=E8=AF=A5=E4=BD=BF=E7=94=A8=E6=9C=80=E5=90=8E?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=9C=89=E6=95=88=E8=A1=8C=E7=9A=84=E7=BC=A9?= =?UTF-8?q?=E8=BF=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script/core/fix-indent.lua | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/script/core/fix-indent.lua b/script/core/fix-indent.lua index c0aaeee1..59adfb7b 100644 --- a/script/core/fix-indent.lua +++ b/script/core/fix-indent.lua @@ -122,18 +122,19 @@ local function fixWrongIndent(state, change) local position = guide.positionOf(change.range.start.line, change.range.start.character) local row = guide.rowColOf(position) local myIndent = getIndent(state, row + 1) - local lastIndent = getIndent(state, row) - if #myIndent <= #lastIndent then + local lastOffset = lookBackward.findAnyOffset(state.lua, guide.positionToOffset(state, position)) + if not lastOffset then return end - if not util.stringStartWith(myIndent, lastIndent) then + local lastPosition = guide.offsetToPosition(state, lastOffset) + local lastRow = guide.rowColOf(lastPosition) + local lastIndent = getIndent(state, lastRow) + if #myIndent <= #lastIndent then return end - local lastOffset = lookBackward.findAnyOffset(state.lua, guide.positionToOffset(state, position)) - if not lastOffset then + if not util.stringStartWith(myIndent, lastIndent) then return end - local lastPosition = guide.offsetToPosition(state, lastOffset) if isInBlock(state, lastPosition) then return end -- cgit v1.2.3