diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2024-08-02 16:49:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2024-08-02 16:49:49 +0800 |
commit | bc303ac5063352663b995a0a16d7d082a5561f24 (patch) | |
tree | 2bd916c4a904b729259729ad550240fbe66972aa | |
parent | 8ecec087ee48501252699b2759b00056db6ef298 (diff) | |
download | lua-language-server-bc303ac5063352663b995a0a16d7d082a5561f24.zip |
Disable indentation fixing for Non-VSCode
fix 2778
-rw-r--r-- | changelog.md | 1 | ||||
-rw-r--r-- | script/core/fix-indent.lua | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/changelog.md b/changelog.md index 94cf4a1c..f67f26b0 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,7 @@ ## 3.10.1 * `FIX` Runtime error +* `FIX` Disable indentation fixing for Non-VSCode ## 3.10.0 `2024-8-1` diff --git a/script/core/fix-indent.lua b/script/core/fix-indent.lua index f9564dd8..8513c4a8 100644 --- a/script/core/fix-indent.lua +++ b/script/core/fix-indent.lua @@ -3,6 +3,7 @@ local guide = require 'parser.guide' local proto = require 'proto.proto' local lookBackward = require 'core.look-backward' local util = require 'utility' +local client = require 'client' ---@param state parser.state ---@param change table @@ -114,7 +115,7 @@ local function isInBlock(state, position) return block ~= nil end -local function fixWrongIdent(state, change) +local function fixWrongIndent(state, change) if not change.text:match '^\r?\n[\t ]+$' then return false end @@ -189,6 +190,9 @@ local function applyEdits(state, edits) end return function (uri, changes) + if not client.getOption('fixIndents') then + return + end local state = files.compileState(uri) if not state then return @@ -197,7 +201,7 @@ return function (uri, changes) local firstChange = changes[1] if firstChange.range then local edits = removeSpacesAfterEnter(state, firstChange) - or fixWrongIdent(state, firstChange) + or fixWrongIndent(state, firstChange) if edits then applyEdits(state, edits) end |