From 065afc28c2730a61003556fbc5f507de20994d82 Mon Sep 17 00:00:00 2001 From: Joe Cheng Date: Thu, 10 Feb 2011 16:57:04 +0800 Subject: [PATCH] Improve wrap mode behavior when wrap limit changes - The cursor wasn't repainting in its new position - Incorrect content width due to session.getScreenWidth() returning a stale value --- lib/ace/edit_session.js | 1 + lib/ace/editor.js | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/ace/edit_session.js b/lib/ace/edit_session.js index 3d0731ef..d06147ae 100644 --- a/lib/ace/edit_session.js +++ b/lib/ace/edit_session.js @@ -669,6 +669,7 @@ var EditSession = function(text, mode) { this.setWrapLimit = function(wrapLimit) { if (wrapLimit != this.$wrapLimit) { this.$wrapLimit = wrapLimit; + this.$modified = true; if (this.$useWrapMode) { this.$updateWrapData(0, this.getLength() - 1); } diff --git a/lib/ace/editor.js b/lib/ace/editor.js index aadae77f..a0669372 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -149,7 +149,7 @@ var Editor =function(renderer, session) { this.$onDocumentChangeTabSize = this.renderer.updateText.bind(this.renderer); session.addEventListener("changeTabSize", this.$onDocumentChangeTabSize); - this.$onDocumentChangeWrapMode = this.renderer.updateFull.bind(this.renderer); + this.$onDocumentChangeWrapMode = this.onDocumentChangeWrapMode.bind(this); session.addEventListener("changeWrapMode", this.$onDocumentChangeWrapMode); this.$onDocumentChangeBreakpoint = this.onDocumentChangeBreakpoint.bind(this); @@ -348,6 +348,11 @@ var Editor =function(renderer, session) { this.renderer.setTokenizer(this.bgTokenizer); }; + this.onDocumentChangeWrapMode = function() { + this.renderer.updateCursor(this.getCursorPosition(), this.$overwrite); + this.renderer.updateFull(); + }; + this.getCopyText = function() { if (!this.selection.isEmpty()) { return this.session.getTextRange(this.getSelectionRange());