From e1bcfb8983c12cbfaffaed1dafdf04f49c345ff3 Mon Sep 17 00:00:00 2001 From: 10sr <8slashes+git@gmail.com> Date: Tue, 29 Nov 2016 02:12:32 +0900 Subject: [PATCH] Fix editorconfig error --- micro/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/micro/init.lua b/micro/init.lua index 76b208b..bcc40b9 100644 --- a/micro/init.lua +++ b/micro/init.lua @@ -57,13 +57,13 @@ local function applyProperties(properties, view) end function onEditorConfigExit(output) - -- FIXME: messege when editorconfig exit with error local properties = {} - -- TODO: Which is better? output:gmatch(), string.gmatch(output, ...) for line in output:gmatch('([^\n]+)') do - -- TODO: Fix regex - -- TODO: Throw error for invalid output local key, value = line:match('([^=]*)=(.*)') + if key == nil or value == nil then + messenger:Message("Failed to parse editorconfig output: " .. output) + return + end key = key:gsub('^%s(.-)%s*$', '%1') value = value:gsub('^%s(.-)%s*$', '%1') properties[key] = value