From 17ad6881e6f3940115987092e77f13154d1fdcb6 Mon Sep 17 00:00:00 2001 From: Simon Lydell Date: Sun, 2 Oct 2016 09:48:55 +0200 Subject: [PATCH] Fix the `'` mark after using `''` The `'` mark is supposed to point to the location before the last "jump." One such jump is using the `'` mark itself (by pressing `''`). This means that running `''` several times in a row will flip back and forth between two locations. However, that was previously broken. `''` took you back to the last location, but then you got stuck there. This commit fixes that bug. Refs. #814. --- extension/lib/commands-frame.coffee | 5 ++++- extension/lib/commands.coffee | 9 ++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/extension/lib/commands-frame.coffee b/extension/lib/commands-frame.coffee index 15d3ee1..4b5b0e4 100644 --- a/extension/lib/commands-frame.coffee +++ b/extension/lib/commands-frame.coffee @@ -106,13 +106,16 @@ commands.mark_scroll_position = ({vim, keyStr, notify = true}) -> vim.notify(translate('notification.mark_scroll_position.success', keyStr)) commands.scroll_to_mark = (args) -> - {vim, amounts: keyStr} = args + {vim, extra: {keyStr, lastPositionMark}} = args + unless keyStr of vim.state.marks vim.notify(translate('notification.scroll_to_mark.none', keyStr)) return args.amounts = vim.state.marks[keyStr] element = vim.state.scrollableElements.filterSuitableDefault() + + commands.mark_scroll_position({vim, keyStr: lastPositionMark, notify: false}) viewportUtils.scroll(element, args) helper_follow = (options, matcher, {vim, pass}) -> diff --git a/extension/lib/commands.coffee b/extension/lib/commands.coffee index aa93d9b..dff86e2 100644 --- a/extension/lib/commands.coffee +++ b/extension/lib/commands.coffee @@ -155,10 +155,10 @@ springConstant = { helper_scroll = (vim, event, args...) -> [ method, type, directions, amounts - properties = null, adjustment = 0, name = 'scroll' + properties = null, adjustment = 0, name = 'scroll', extra = {} ] = args options = { - method, type, directions, amounts, properties, adjustment + method, type, directions, amounts, properties, adjustment, extra smooth: ( prefs.root.get('general.smoothScroll') and prefs.root.get("general.smoothScroll.#{type}") @@ -253,11 +253,10 @@ commands.mark_scroll_position = ({vim}) -> commands.scroll_to_mark = ({vim}) -> vim._enterMode('marks', (keyStr) -> - unless keyStr == vim.options['scroll.last_position_mark'] - helper_mark_last_scroll_position(vim) helper_scroll( - vim, null, 'scrollTo', 'other', ['top', 'left'], keyStr, + vim, null, 'scrollTo', 'other', ['top', 'left'], [0, 0] ['scrollTopMax', 'scrollLeftMax'], 0, 'scroll_to_mark' + {keyStr, lastPositionMark: vim.options['scroll.last_position_mark']} ) vim.hideNotification() ) -- 2.39.3