From b27f5cd86519da5ea35c743220c74f6fe004855a Mon Sep 17 00:00:00 2001 From: Alexey Mikitevich <> Date: Mon, 3 Feb 2020 02:43:43 +0300 Subject: [PATCH] add option with jump cursor position --- findJump/package.json | 18 +++++++++++++++++- findJump/src/findJump.ts | 5 ++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/findJump/package.json b/findJump/package.json index 4e9cec6..19fe987 100644 --- a/findJump/package.json +++ b/findJump/package.json @@ -24,7 +24,23 @@ "command": "findJump.activateWithSelection", "title": "Activate Find-Jump in selection mode" } - ] + ], + "configuration": { + "title": "Find-Jump", + "properties": { + "findJump.jumpCursorPosition": { + "type": "string", + "default": "start", + "enum": [ + "start", + "end" + ], + "enumDescriptions": [ + "Place where to put cursor: before searching range or after" + ] + } + } + } }, "scripts": { "vscode:prepublish": "tsc -p ./", diff --git a/findJump/src/findJump.ts b/findJump/src/findJump.ts index 25d4a66..c6cb39d 100644 --- a/findJump/src/findJump.ts +++ b/findJump/src/findJump.ts @@ -3,6 +3,7 @@ import { TextEditor, TextLine, Range, + workspace } from 'vscode' import {InlineInput} from './inlineInput' import {documentRippleScanner} from './documentRippleScanner' @@ -22,6 +23,7 @@ export class FindJump { activityIndicatorState = 0 activatedWithSelection = false searchFunctionDebounceTracker: any + workspaceFindJumpConfig = workspace.getConfiguration('findJump'); activate = (textEditor: TextEditor) => { this.textEditor = textEditor @@ -96,7 +98,8 @@ export class FindJump { return } - const {line, character} = range.start + const cursorPosition = this.workspaceFindJumpConfig.get('jumpCursorPosition', 'start'); + const {line, character} = this.activatedWithSelection ? range.start : range[cursorPosition] this.textEditor.selection = new Selection( this.activatedWithSelection ? this.textEditor.selection.start.line : line,