From d68ccc2778f2df83dc480be8c74c06cb4b6e602b Mon Sep 17 00:00:00 2001 From: Yukai Huang Date: Thu, 20 Aug 2020 14:30:12 +0800 Subject: [PATCH] Fix csv regex undefined matching group Ref: https://github.com/codemirror/CodeMirror/issues/5374#issuecomment-384219584 --- addon/mode/simple.js | 2 +- mode/csv/csv.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/addon/mode/simple.js b/addon/mode/simple.js index ed6ddb4f828..655f9914757 100644 --- a/addon/mode/simple.js +++ b/addon/mode/simple.js @@ -94,7 +94,7 @@ function tokenFunction(states, config) { return function(stream, state) { - if (state.pending && state.pending.length > 0) { + if (state.pending) { var pend = state.pending.shift(); if (state.pending.length == 0) state.pending = null; stream.pos += pend.text.length; diff --git a/mode/csv/csv.js b/mode/csv/csv.js index d3b79af217f..93d9efe58e9 100644 --- a/mode/csv/csv.js +++ b/mode/csv/csv.js @@ -10,7 +10,7 @@ CodeMirror.defineSimpleMode('csv', { start: [ { - regex: /((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?((?: *\"(?:[^\"]*\"\")*[^\"]*\" *(?:,|$))|(?:[^,]*(?:,|$)))?/, + regex: /((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)((?: *"(?:[^"]*"")*[^"]*" *(?:,|$))|(?:[^,]*(?:,|$))|)/, token: [ "variable", "keyword",