Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Make argcount warning highlight only function names

  • Loading branch information...
commit 22b75bcf657d4f55e48cce3801613ee3e3086af1 1 parent 9d3f187
Peter Odding authored August 19, 2010
5  TODO.md
Source Rendered
@@ -5,4 +5,7 @@
5 5
  * Check whether "core/SciTE: jump to definition now supports functions in different files." is interesting.
6 6
  * Argument count warning tool tips are only shown for parts of the highlighted text. This might have been fixed in recent changes to LuaInspect.
7 7
  * Bug: The plug-in sometimes warns `Invalid output from luainspect4vim.lua: 'This is an unknown table field.'`. Mixup between tool tip / highlight response parsing?!
8  
- * Dynamic highlighting using `matchadd()` performs **very** poorly when multiple consecutive lines are highlighted as `SpellLocal` -- so poorly that Vim becomes pretty much unusable until the user disables dynamic highlighting using `:LuaInspect!` (e.g. try editing `luainspect/init.lua` using the Vim plug-in). For this reason I guess only the function names should be highlighted.
  8
+
  9
+# Known issues
  10
+
  11
+ * Dynamic highlighting using Vim's `matchadd()` function performs **very** poorly in large buffers -- so poorly that Vim becomes pretty much unusable until the user disables dynamic highlighting using `:LuaInspect!` (e.g. try editing `luainspect/scite.lua` using the Vim plug-in). I've since switched to highlighting only function names (instead of multiline call expressions) but that hasn't improved performance as much as I'd hoped...
17  luainspect4vim.lua
@@ -57,8 +57,21 @@ function actions.highlight(tokenlist, line, column, src) -- {{{1
57 57
     if curvar and curvar.ast.id == token.ast.id then
58 58
       dump(token, 'luaInspectSelectedVariable')
59 59
     end
60  
-    if token.ast.note and token.ast.note:find '[Tt]oo%s+%w+%s+arguments' then
61  
-      dump(token, 'luaInspectWrongArgCount')
  60
+    local ast = token.ast
  61
+    if ast and (ast.seevalue or ast).note then
  62
+      local hast = ast.seevalue or ast
  63
+      if hast.tag == 'Call' then
  64
+        hast = hast[1]
  65
+      elseif hast.tag == 'Invoke' then
  66
+        hast = hast[2]
  67
+      end
  68
+      local fpos, lpos = LA.ast_pos_range(hast, tokenlist)
  69
+      local l1, c1 = LA.pos_to_linecol(fpos, src)
  70
+      local l2, c2 = LA.pos_to_linecol(lpos, src)
  71
+      -- TODO: A bit confusing is that LuaInspect seems to emit both zero-based
  72
+      -- and one-based column numbers (i.e. offsets vs. indices) since the
  73
+      -- included Metalua lexer was patched to fix a rare bug.
  74
+      myprint(('luaInspectWrongArgCount %i %i %i %i'):format(l1, c1 - 1, l2, c2 - 1))
62 75
     end
63 76
     if token.tag == 'Id' then
64 77
       if not token.ast.localdefinition then

0 notes on commit 22b75bc

Please sign in to comment.
Something went wrong with that request. Please try again.