diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/core/signature.lua | 22 | ||||
-rw-r--r-- | script/parser/guide.lua | 8 |
2 files changed, 26 insertions, 4 deletions
diff --git a/script/core/signature.lua b/script/core/signature.lua index ab6d133a..295b5437 100644 --- a/script/core/signature.lua +++ b/script/core/signature.lua @@ -99,11 +99,33 @@ local function makeSignatures(call, pos) return signs end +local function isSpace(char) + if char == ' ' + or char == '\n' + or char == '\r' + or char == '\t' then + return true + end + return false +end + +local function skipSpace(text, offset) + for i = offset, 1, -1 do + local char = text:sub(i, i) + if not isSpace(char) then + return i + end + end + return 0 +end + return function (uri, pos) local ast = files.getAst(uri) if not ast then return nil end + local text = files.getText(uri) + pos = skipSpace(text, pos) local call = findNearCall(uri, ast, pos) if not call then return nil diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 98dca211..c34e65f9 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -460,7 +460,7 @@ function m.isContain(source, offset) if not start then return false end - return start <= offset and finish >= offset - 1 + return start <= offset and finish >= offset end --- 判断offset在source的影响范围内 @@ -471,7 +471,7 @@ function m.isInRange(source, offset) if not start then return false end - return start <= offset and finish >= offset - 1 + return start <= offset and finish >= offset end function m.isBetween(source, tStart, tFinish) @@ -479,7 +479,7 @@ function m.isBetween(source, tStart, tFinish) if not start then return false end - return start <= tFinish and finish >= tStart - 1 + return start <= tFinish and finish >= tStart end function m.isBetweenRange(source, tStart, tFinish) @@ -487,7 +487,7 @@ function m.isBetweenRange(source, tStart, tFinish) if not start then return false end - return start <= tFinish and finish >= tStart - 1 + return start <= tFinish and finish >= tStart end --- 添加child |