From 787466fc40fcf5804c82cb81d68705c0ffdcdd31 Mon Sep 17 00:00:00 2001 From: tophf Date: Tue, 14 Jul 2020 23:25:19 +0300 Subject: [PATCH] consume leftovers when auto-completing properties (#992) --- edit/codemirror-default.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/edit/codemirror-default.js b/edit/codemirror-default.js index 4b43b378..63ec2423 100644 --- a/edit/codemirror-default.js +++ b/edit/codemirror-default.js @@ -315,6 +315,7 @@ CodeMirror.hint && (() => { const RX_IMPORTANT = /(i(m(p(o(r(t(a(nt?)?)?)?)?)?)?)?)?(?=\b|\W|$)/iy; const RX_VAR_KEYWORD = /(^|[^-\w\u0080-\uFFFF])var\(/iy; const RX_END_OF_VAR = /[\s,)]|$/g; + const RX_CONSUME_PROP = /[-\w]*\s*:\s?|$/y; const originalHelper = CodeMirror.hint.css || (() => {}); const helper = cm => { @@ -385,6 +386,8 @@ CodeMirror.hint && (() => { const state = res && cm.getTokenAt(pos).state.state; if (state === 'block' || state === 'maybeprop') { res.list = res.list.map(str => str + ': '); + RX_CONSUME_PROP.lastIndex = res.to.ch; + res.to.ch += RX_CONSUME_PROP.exec(text)[0].length; } return res; }