penguin/AstroJS

Javascript framework for my blog

commit 79705e9b1404b848cd11bc2801270633e2ee657a

author斟酌 鵬兄 <tgckpg@gmail.com>
date2016-03-30T19:12:18Z
subjectReset analyzed content when needed
commit 79705e9b1404b848cd11bc2801270633e2ee657a
Author: 斟酌 鵬兄 <tgckpg@gmail.com>
Date:   2016-03-30T19:12:18Z

    Reset analyzed content when needed
---
 botanjs/src/Components/Vim/Cursor.js                  | 15 ++++++++++-----
 botanjs/src/Components/Vim/Syntax/Analyzer.js         |  5 +++++
 botanjs/src/externs/Components.Vim.Syntax.Analyzer.js |  2 ++
 3 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/botanjs/src/Components/Vim/Cursor.js b/botanjs/src/Components/Vim/Cursor.js
index 47b10ad..ce66bd8 100644
--- a/botanjs/src/Components/Vim/Cursor.js
+++ b/botanjs/src/Components/Vim/Cursor.js
@@ -191,10 +191,10 @@
 		this.PEnd = P + 1;
 		this.__p = P;
 
-		this.__fireUpdate();
+		this.__visualUpdate();
 	};
 
-	Cursor.prototype.__fireUpdate = function()
+	Cursor.prototype.__visualUpdate = function()
 	{
 		if( 0 < this.__suppEvt )
 		{
@@ -313,7 +313,7 @@
 		this.action = new (Actions[ name ])( this );
 		this.__pulseMsg = null;
 
-		this.__fireUpdate();
+		this.__visualUpdate();
 	};
 
 	Cursor.prototype.closeAction = function()
@@ -323,7 +323,10 @@
 		this.__pulseMsg = this.action.getMessage();
 		this.action = null;
 
-		this.__fireUpdate();
+		// Reset the analyzed content
+		this.Vim.contentAnalyzer.reset();
+
+		this.__visualUpdate();
 	};
 
 	// Open, Run, then close an action
@@ -335,7 +338,9 @@
 		this.__pulseMsg = action.getMessage();
 		action.dispose();
 
-		this.__fireUpdate();
+		this.Vim.contentAnalyzer.reset();
+
+		this.__visualUpdate();
 	};
 
 	Cursor.prototype.suppressEvent = function() { ++ this.__suppEvt; };
diff --git a/botanjs/src/Components/Vim/Syntax/Analyzer.js b/botanjs/src/Components/Vim/Syntax/Analyzer.js
index 131ec75..54014ce 100644
--- a/botanjs/src/Components/Vim/Syntax/Analyzer.js
+++ b/botanjs/src/Components/Vim/Syntax/Analyzer.js
@@ -277,6 +277,11 @@
 		return pairs;
 	};
 
+	Analyzer.prototype.reset = function()
+	{
+		this.__tokpairs = {};
+	};
+
 	Analyzer.prototype.quoteAt = function( p )
 	{
 		var c = this.__feeder.content;
diff --git a/botanjs/src/externs/Components.Vim.Syntax.Analyzer.js b/botanjs/src/externs/Components.Vim.Syntax.Analyzer.js
index 47a3b3b..24f603c 100644
--- a/botanjs/src/externs/Components.Vim.Syntax.Analyzer.js
+++ b/botanjs/src/externs/Components.Vim.Syntax.Analyzer.js
@@ -9,3 +9,5 @@ Components.Vim.Syntax.Analyzer.bracketIn;
 Components.Vim.Syntax.Analyzer.wordAt;
 /** @type Function */
 Components.Vim.Syntax.Analyzer.quoteAt;
+/** @type Function */
+Components.Vim.Syntax.Analyzer.reset;