Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit 945b410

Browse files
committed
generalize the pattern we use to parse out line numbers of errors from in-shell editing
Fixes #1023
1 parent ccc514e commit 945b410

File tree

1 file changed

+9
-3
lines changed
  • app/plugins/modules/editor/lib

1 file changed

+9
-3
lines changed

app/plugins/modules/editor/lib/edit.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,17 @@ const persisters = {
156156
.catch(err => {
157157
if (err.statusCode === 'ENOPARSE') {
158158
debug('composition did not parse', err)
159+
// try two patterns to spot stack trace information;
160+
// we need to pull out the line number from the stack trace,
161+
// so that we can identify the problem, with a gutter marker ("decoration"),
162+
// in the editor pane
159163
const basename = path.basename(filepath),
160-
pattern = new RegExp('\\n([^\n]+)\\n\\s+at\\s+' + basename.replace(/\./, '\\.') + ':(\\d+):(\\d+)'),
161-
match = err.message.match(pattern)
164+
pattern1 = new RegExp('\\n([^\n]+)\\n\\s+at\\s+' + basename.replace(/\./, '\\.') + ':(\\d+):(\\d+)'),
162165

163-
debug('pattern', pattern)
166+
pattern2 = new RegExp('([^\n]+)\\n\\s+at\\s+[^\\(]*\\s+\\([^\n\r]*' + basename.replace(/\./, '\\.') + ':(\\d+):(\\d+)'),
167+
match = err.message.match(pattern1) || err.message.match(pattern2)
168+
169+
debug('pattern', pattern1, pattern2)
164170
debug('message', err.message)
165171
if (match) {
166172
const problem = match[1],

0 commit comments

Comments
 (0)