editor.setSession must update wraplimit
This commit is contained in:
parent
09bda14096
commit
e32a760ef1
2 changed files with 20 additions and 17 deletions
|
|
@ -192,6 +192,7 @@ var Editor =function(renderer, session) {
|
||||||
this.onChangeBackMarker();
|
this.onChangeBackMarker();
|
||||||
this.onChangeBreakpoint();
|
this.onChangeBreakpoint();
|
||||||
this.onChangeAnnotation();
|
this.onChangeAnnotation();
|
||||||
|
this.session.getUseWrapMode() && this.renderer.adjustWrapLimit();
|
||||||
this.renderer.scrollToRow(session.getScrollTopRow());
|
this.renderer.scrollToRow(session.getScrollTopRow());
|
||||||
this.renderer.updateFull();
|
this.renderer.updateFull();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -201,13 +201,15 @@ var VirtualRenderer = function(container, theme) {
|
||||||
*/
|
*/
|
||||||
this.onResize = function(force) {
|
this.onResize = function(force) {
|
||||||
var changes = this.CHANGE_SIZE;
|
var changes = this.CHANGE_SIZE;
|
||||||
|
var size = this.$size;
|
||||||
|
|
||||||
var height = dom.getInnerHeight(this.container);
|
var height = dom.getInnerHeight(this.container);
|
||||||
if (force || this.$size.height != height) {
|
if (force || size.height != height) {
|
||||||
this.$size.height = height;
|
size.height = height;
|
||||||
|
|
||||||
this.scroller.style.height = height + "px";
|
this.scroller.style.height = height + "px";
|
||||||
this.scrollBar.setHeight(this.scroller.clientHeight);
|
size.scrollerHeight = this.scroller.clientHeight;
|
||||||
|
this.scrollBar.setHeight(size.scrollerHeight);
|
||||||
|
|
||||||
if (this.session) {
|
if (this.session) {
|
||||||
this.scrollToY(this.getScrollTop());
|
this.scrollToY(this.getScrollTop());
|
||||||
|
|
@ -216,27 +218,27 @@ var VirtualRenderer = function(container, theme) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var width = dom.getInnerWidth(this.container);
|
var width = dom.getInnerWidth(this.container);
|
||||||
if (force || this.$size.width != width) {
|
if (force || size.width != width) {
|
||||||
this.$size.width = width;
|
size.width = width;
|
||||||
|
|
||||||
var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
|
var gutterWidth = this.showGutter ? this.$gutter.offsetWidth : 0;
|
||||||
this.scroller.style.left = gutterWidth + "px";
|
this.scroller.style.left = gutterWidth + "px";
|
||||||
this.scroller.style.width = Math.max(0, width - gutterWidth - this.scrollBar.getWidth()) + "px";
|
size.scrollerWidth = Math.max(0, width - gutterWidth - this.scrollBar.getWidth())
|
||||||
|
this.scroller.style.width = size.scrollerWidth + "px";
|
||||||
|
|
||||||
if (this.session.getUseWrapMode()) {
|
if (this.session.getUseWrapMode() && this.adjustWrapLimit() || force)
|
||||||
var availableWidth = this.scroller.clientWidth - this.$padding * 2;
|
|
||||||
var limit = Math.floor(availableWidth / this.characterWidth) - 1;
|
|
||||||
if (this.session.adjustWrapLimit(limit) || force) {
|
|
||||||
changes = changes | this.CHANGE_FULL;
|
changes = changes | this.CHANGE_FULL;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$size.scrollerWidth = this.scroller.clientWidth;
|
|
||||||
this.$size.scrollerHeight = this.scroller.clientHeight;
|
|
||||||
this.$loop.schedule(changes);
|
this.$loop.schedule(changes);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.adjustWrapLimit = function(){
|
||||||
|
var availableWidth = this.$size.scrollerWidth - this.$padding * 2;
|
||||||
|
var limit = Math.floor(availableWidth / this.characterWidth) - 1;
|
||||||
|
return this.session.adjustWrapLimit(limit);
|
||||||
|
};
|
||||||
|
|
||||||
this.$onGutterClick = function(e) {
|
this.$onGutterClick = function(e) {
|
||||||
var pageX = event.getDocumentX(e);
|
var pageX = event.getDocumentX(e);
|
||||||
var pageY = event.getDocumentY(e);
|
var pageY = event.getDocumentY(e);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue