From 0da0566bacc38663cc66899feb246aee378660af Mon Sep 17 00:00:00 2001 From: nightwing Date: Sat, 24 Jan 2015 18:53:41 +0400 Subject: [PATCH] fix pagedown in vim mode --- lib/ace/keyboard/vim.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/ace/keyboard/vim.js b/lib/ace/keyboard/vim.js index 4ef12ca4..7312821f 100644 --- a/lib/ace/keyboard/vim.js +++ b/lib/ace/keyboard/vim.js @@ -391,13 +391,19 @@ define(function(require, exports, module) { sel.moveCursorBy(0, increment); } }; - this.findPosV = function(start, amaount, unit, goalColumn) { + this.findPosV = function(start, amount, unit, goalColumn) { + if (unit == 'page') { + var renderer = this.ace.renderer; + var config = renderer.layerConfig; + amount = amount * Math.floor(config.height / config.lineHeight); + unit = 'line'; + } if (unit == 'line') { var screenPos = this.ace.session.documentToScreenPosition(start.line, start.ch); if (goalColumn != null) screenPos.column = goalColumn; - screenPos.row += amaount; - // not what codemirror does but vim mode needs only it + screenPos.row += amount; + // not what codemirror does but vim mode needs only this screenPos.row = Math.min(Math.max(0, screenPos.row), this.ace.session.getScreenLength() - 1); var pos = this.ace.session.screenToDocumentPosition(screenPos.row, screenPos.column); return toCmPos(pos);