From 032a024a4d3ee28c490e39a5faa2f40518ba0c05 Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Thu, 21 Jan 2016 15:44:33 +0100 Subject: [PATCH] Adds column matching to the linter --- CHANGELOG.md | 3 +++ lib/linter-mzn.coffee | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eccef63..f58e45c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.5.0 - Column matching +- The linter now indicates the right column if indicated by `mzn2fzn` + ## 0.4.1 - Enables the user to disable linting in the package settings - Fixes problem in highlighting of numerical constants diff --git a/lib/linter-mzn.coffee b/lib/linter-mzn.coffee index 8207205..7f2e306 100644 --- a/lib/linter-mzn.coffee +++ b/lib/linter-mzn.coffee @@ -53,17 +53,20 @@ class LinterMZN generateMessage: (output, filePath) -> match = output[0].match(/:([0-9]+):/) line = parseInt(match[1]) - console.log line + '\n' + + startcol = 0 + endcol = 500; + if output.length > 2 and /\^/.test(output[2]) + startcol = output[2].match(/\^/).index + endcol = output[2].match(/\^(\s|$)/).index + 1 message = { type: 'Error', text: output[1..].join('\n').replace(/MiniZinc: /, ""), - range: [[line-1,0], [line-1,500]], + range: [[line-1,startcol], [line-1,endcol]], filePath: filePath, } - console.log message - return message