diff options
author | 2015-09-04 12:15:20 -0400 | |
---|---|---|
committer | 2015-09-04 12:15:20 -0400 | |
commit | 3d9fdb23e2c2eb51ea49540daf7b9a0016e46fb3 (patch) | |
tree | c5f84dee40df1489751f19b956d93c20c4db3c49 /modules/textadept | |
parent | fbb26ef274d1d8928524cea07a28588df99ddd0d (diff) | |
download | textadept-3d9fdb23e2c2eb51ea49540daf7b9a0016e46fb3.tar.gz textadept-3d9fdb23e2c2eb51ea49540daf7b9a0016e46fb3.zip |
Use `spawn()` for syntax checking; modules/textadept/run.lua
This prevents the black box popup on Windows.
This requires lspawn r38 (changeset 7683f6d2d678).
Diffstat (limited to 'modules/textadept')
-rw-r--r-- | modules/textadept/run.lua | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/modules/textadept/run.lua b/modules/textadept/run.lua index e02fd344..97737cb6 100644 --- a/modules/textadept/run.lua +++ b/modules/textadept/run.lua @@ -372,37 +372,38 @@ events.connect(events.FILE_AFTER_SAVE, function(filename) if not command or not patt then return end -- Run the syntax checker command and look for errors. buffer:annotation_clear_all() - local p = io.popen(command:gsub('%%f', filename)..' 2>&1') - local out = p:read('*a') - p:close() - local captures = {message = '', out:match(patt)} - if #captures == 0 then return end - -- Parse out the line, column, and error message. - for detail in patt:gmatch('[^%%](%b())') do - if detail == '(%d+)' then - local source = not captures.line and 'line' or 'column' - captures[source] = tonumber(table.remove(captures, 1)) - 1 - elseif detail == '(%s*)' then - captures.column = #table.remove(captures, 1) - else - captures.message = captures.message..table.remove(captures, 1) + local out = {} + local output = function(output) out[#out + 1] = output end + spawn(command:gsub('%%f', filename), nil, output, output, function() + local captures = {message = '', table.concat(out):match(patt)} + if #captures == 0 then return end + -- Parse out the line, column, and error message. + for detail in patt:gmatch('[^%%](%b())') do + if detail == '(%d+)' then + local source = not captures.line and 'line' or 'column' + captures[source] = tonumber(table.remove(captures, 1)) - 1 + elseif detail == '(%s*)' then + captures.column = #table.remove(captures, 1) + else + captures.message = captures.message..table.remove(captures, 1) + end end - end - if not captures.line or not captures.message then return end - -- Display the annotation and either jump to, or note the position. - buffer.annotation_text[captures.line] = captures.message - buffer.annotation_style[captures.line] = 8 -- error style number - local top_line = buffer:doc_line_from_visible(buffer.first_visible_line) - local bottom_line = buffer:doc_line_from_visible(buffer.first_visible_line + - buffer.lines_on_screen) - 1 - if M.GOTO_SYNTAX_ERRORS then - buffer:goto_pos(buffer:find_column(captures.line, captures.column or 0)) - elseif captures.line < top_line or captures.line > bottom_line then - local line = buffer:line_from_position(buffer.current_pos) - buffer.annotation_text[line] = 'Line '..(captures.line + 1)..'\n'.. - captures.message - buffer.annotation_style[line] = 8 -- error style number - end + if not captures.line or not captures.message then return end + -- Display the annotation and either jump to, or note the position. + buffer.annotation_text[captures.line] = captures.message + buffer.annotation_style[captures.line] = 8 -- error style number + local top_line = buffer:doc_line_from_visible(buffer.first_visible_line) + local bottom_line = buffer:doc_line_from_visible(buffer.first_visible_line + + buffer.lines_on_screen) - 1 + if M.GOTO_SYNTAX_ERRORS then + buffer:goto_pos(buffer:find_column(captures.line, captures.column or 0)) + elseif captures.line < top_line or captures.line > bottom_line then + local line = buffer:line_from_position(buffer.current_pos) + buffer.annotation_text[line] = 'Line '..(captures.line + 1)..'\n'.. + captures.message + buffer.annotation_style[line] = 8 -- error style number + end + end) end) return M |