Skip to content

Commit 7134e48

Browse files
committed
[rst mode] Better innerMode implementation
Also fixes CodeMirror.innerMode to give up on null or fixpoint Issue #1704
1 parent 4a3ad9b commit 7134e48

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

lib/codemirror.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3358,6 +3358,7 @@ window.CodeMirror = (function() {
33583358
CodeMirror.innerMode = function(mode, state) {
33593359
while (mode.innerMode) {
33603360
var info = mode.innerMode(state);
3361+
if (!info || info.mode == mode) break;
33613362
state = info.state;
33623363
mode = info.mode;
33633364
}

mode/rst/rst.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,9 @@ CodeMirror.defineMode('rst-base', function (config) {
482482
},
483483

484484
innerMode: function (state) {
485-
return {state: state.ctx.local, mode: state.ctx.mode};
485+
return state.tmp ? {state: state.tmp.local, mode: state.tmp.mode}
486+
: state.ctx ? {state: state.ctx.local, mode: state.ctx.mode}
487+
: null;
486488
},
487489

488490
token: function (stream, state) {

0 commit comments

Comments
 (0)