Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improve syntax error messages for unnamed buffers

  • Loading branch information...
commit 3cbe412883edda9ce4cc87368d6b8f2ddbc29978 1 parent 07d1f44
Peter Odding authored August 22, 2010
14  autoload.vim
... ...
@@ -1,6 +1,6 @@
1 1
 " Vim script.
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: August 19, 2010
  3
+" Last Change: August 21, 2010
4 4
 " URL: http://peterodding.com/code/vim/lua-inspect/
5 5
 " License: MIT
6 6
 
@@ -38,7 +38,11 @@ endfunction
38 38
 
39 39
 function! luainspect#make_request(action) " {{{1
40 40
   let starttime = xolox#timer#start()
41  
-  let bufname = fnamemodify(bufname(a:action != 'tooltip' ? '%' : v:beval_bufnr), ':p')
  41
+  let bufnr = a:action != 'tooltip' ? bufnr('%') : v:beval_bufnr
  42
+  let bufname = bufname(bufnr)
  43
+  if bufname != ''
  44
+    let bufname = fnamemodify(bufname, ':p')
  45
+  endif
42 46
   if a:action == 'tooltip'
43 47
     let lines = getbufline(v:beval_bufnr, 1, "$")
44 48
     call insert(lines, v:beval_col)
@@ -53,7 +57,11 @@ function! luainspect#make_request(action) " {{{1
53 57
   call s:parse_text(join(lines, "\n"), s:prepare_search_path())
54 58
   if !empty(b:luainspect_output)
55 59
     let response = b:luainspect_output[0]
56  
-    let friendlyname = fnamemodify(bufname, ':~')
  60
+    if bufname == ''
  61
+      let friendlyname = 'buffer #' . bufnr
  62
+    else
  63
+      let friendlyname = fnamemodify(bufname, ':~')
  64
+    endif
57 65
     if response == 'syntax_error' && len(b:luainspect_output) >= 4
58 66
       " Never perform syntax error highlighting in non-Lua buffers!
59 67
       let linenum = b:luainspect_output[1] + 0
4  luainspect.vim
... ...
@@ -1,8 +1,8 @@
1 1
 " Vim plug-in
2 2
 " Author: Peter Odding <peter@peterodding.com>
3  
-" Last Change: August 19, 2010
  3
+" Last Change: August 21, 2010
4 4
 " URL: http://peterodding.com/code/vim/lua-inspect/
5  
-" Version: 0.4.5
  5
+" Version: 0.4.6
6 6
 " License: MIT
7 7
 
8 8
 " Support for automatic update using the GLVS plug-in.
4  luainspect4vim.lua
@@ -3,7 +3,7 @@
3 3
  This module is part of the luainspect.vim plug-in for the Vim text editor.
4 4
 
5 5
  Author: Peter Odding <peter@peterodding.com>
6  
- Last Change: August 19, 2010
  6
+ Last Change: August 21, 2010
7 7
  URL: http://peterodding.com/code/vim/lua-inspect/
8 8
  License: MIT
9 9
 
@@ -180,7 +180,7 @@ end
180 180
 
181 181
 return function(src)
182 182
   local action, file, line, column
183  
-  action, file, line, column, src = src:match '^(%S+)\n([^\n]+)\n(%d+)\n(%d+)\n(.*)$'
  183
+  action, file, line, column, src = src:match '^(%S+)\n([^\n]*)\n(%d+)\n(%d+)\n(.*)$'
184 184
   line = tonumber(line)
185 185
   -- This adjustment was found by trial and error :-|
186 186
   column = tonumber(column) - 1

0 notes on commit 3cbe412

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