summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2024-08-06 21:09:01 +0800
committer最萌小汐 <sumneko@hotmail.com>2024-08-06 21:09:01 +0800
commit1dbe571cfe8b003f539f09385d7b719f7f13b381 (patch)
tree98535766c58975bb7607006019a9500435b5b724
parenta7a40a5b095f0d7dde928ec14560af1818aa3f5c (diff)
downloadlua-language-server-1dbe571cfe8b003f539f09385d7b719f7f13b381.zip
应该使用最后一个有效行的缩进
-rw-r--r--script/core/fix-indent.lua13
1 files 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