From 94e4a4b4dafacf0187c0ae46f0452147c89fb421 Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke <marijnh@gmail.com> Date: Thu, 6 Feb 2014 11:09:56 +0100 Subject: [PATCH] [rst mode] Fix innerMode and copyState Issue #2221 --- mode/rst/rst.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mode/rst/rst.js b/mode/rst/rst.js index 75563ba98..e8ebb63e2 100644 --- a/mode/rst/rst.js +++ b/mode/rst/rst.js @@ -477,13 +477,18 @@ CodeMirror.defineMode('rst-base', function (config) { }, copyState: function (state) { - return {tok: state.tok, ctx: state.ctx}; + var ctx = state.ctx, tmp = state.tmp; + if (ctx.local) + ctx = {mode: ctx.mode, local: CodeMirror.copyState(ctx.mode, ctx.local)}; + if (tmp) + tmp = {mode: tmp.mode, local: CodeMirror.copyState(tmp.mode, tmp.local)}; + return {tok: state.tok, ctx: ctx, tmp: tmp}; }, innerMode: function (state) { - return state.tmp ? {state: state.tmp.local, mode: state.tmp.mode} - : state.ctx ? {state: state.ctx.local, mode: state.ctx.mode} - : null; + return state.tmp ? {state: state.tmp.local, mode: state.tmp.mode} + : state.ctx.mode ? {state: state.ctx.local, mode: state.ctx.mode} + : null; }, token: function (stream, state) { -- GitLab