diff options
-rw-r--r-- | script/core/diagnostics/trailing-space.lua | 18 | ||||
-rw-r--r-- | test/diagnostics/common.lua | 9 |
2 files changed, 22 insertions, 5 deletions
diff --git a/script/core/diagnostics/trailing-space.lua b/script/core/diagnostics/trailing-space.lua index d23b0692..b9e4d32d 100644 --- a/script/core/diagnostics/trailing-space.lua +++ b/script/core/diagnostics/trailing-space.lua @@ -3,13 +3,20 @@ local lang = require 'language' local guide = require 'parser.guide' local function isInString(ast, offset) - local result = false - guide.eachSourceType(ast, 'string', function (source) + return guide.eachSourceType(ast, 'string', function (source) if offset >= source.start and offset <= source.finish then - result = true + return true end end) - return result +end + +local function isInComment(ast, offset) + for _, com in ipairs(ast.state.comms) do + if offset >= com.start and offset <= com.finish then + return true + end + end + return false end return function (uri, callback) @@ -28,7 +35,8 @@ return function (uri, callback) goto NEXT_LINE end local lastPos = guide.offsetToPosition(state, lastOffset) - if isInString(state.ast, lastPos) then + if isInString(state.ast, lastPos) + or isInComment(state.ast, lastPos) then goto NEXT_LINE end local firstOffset = startOffset diff --git a/test/diagnostics/common.lua b/test/diagnostics/common.lua index 759039a6..e88fbf43 100644 --- a/test/diagnostics/common.lua +++ b/test/diagnostics/common.lua @@ -87,6 +87,15 @@ X = [=[ ]] TEST [[ +-- xxxx +]] + +TEST [[ +-- [=[ + ]=] +]] + +TEST [[ local x print(x) local <!x!> |