From bc303ac5063352663b995a0a16d7d082a5561f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 2 Aug 2024 16:49:49 +0800 Subject: Disable indentation fixing for Non-VSCode fix 2778 --- changelog.md | 1 + 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 -- cgit v1.2.3