Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added common example for key remapping for £ #3250

Merged
merged 3 commits into from
Dec 10, 2018
Merged

Conversation

ycmjason
Copy link
Contributor

@ycmjason ycmjason commented Dec 8, 2018

What this PR does / why we need it:
Since UK keyboard has shift+3 to be £ instead of #. The command for going to the previous word under cursor wouldn't work. I have been searching online and couldn't find any documentation about this. So I thought would be nice to include at README here.

@TravisBuddy
Copy link

Travis tests have failed

Hey @ycmjason,
Please read the following log in order to understand the failure reason.
It'll be awesome if you fix what's wrong and commit the changes.

Node.js: 8

View build log

if [[ $(git diff-index HEAD -- *.js *.ts *.md) ]]; then git diff; echo "Prettier Failed. Run `gulp forceprettier` and commit changes to resolve."; exit 1; fi
diff --git a/README.md b/README.md
index efad6a1..b73a493 100644
--- a/README.md
+++ b/README.md
@@ -170,6 +170,7 @@ Custom remappings are defined on a per-mode basis.
  • Bind £ to goto previous whole word under cursor
    "vim.normalModeKeyBindings": [
        {
diff --git a/src/mode/modeHandler.ts b/src/mode/modeHandler.ts
index b57ad54..c4727b6 100644
--- a/src/mode/modeHandler.ts
+++ b/src/mode/modeHandler.ts
@@ -72,59 +72,60 @@ export class ModeHandler implements vscode.Disposable {
    ];

    this.vimState = new VimState(vscode.window.activeTextEditor!, configuration.enableNeovim);
-    this.setCurrentMode(configuration.startInInsertMode ? ModeName.Insert : ModeName.Normal).then(() => {
-      // Sometimes, Visual Studio Code will start the cursor in a position which
-      // is not (0, 0) - e.g., if you previously edited the file and left the
-      // cursor somewhere else when you closed it. This will set our cursor's
-      // position to the position that VSC set it to.
-
-      // This also makes things like gd work.
-      // For whatever reason, the editor positions aren't updated until after the
-      // stack clears, which is why this setTimeout is necessary
-      this.syncCursors();
-
-      // Handle scenarios where mouse used to change current position.
-      const onChangeTextEditorSelection = vscode.window.onDidChangeTextEditorSelection(
-        (e: vscode.TextEditorSelectionChangeEvent) => {
-          if (configuration.disableExt) {
-            return;
-          }
-
-          if (Globals.isTesting) {
-            return;
-          }
+    this.setCurrentMode(configuration.startInInsertMode ? ModeName.Insert : ModeName.Normal)
+      .then(() => {
+        // Sometimes, Visual Studio Code will start the cursor in a position which
+        // is not (0, 0) - e.g., if you previously edited the file and left the
+        // cursor somewhere else when you closed it. This will set our cursor's
+        // position to the position that VSC set it to.
+
+        // This also makes things like gd work.
+        // For whatever reason, the editor positions aren't updated until after the
+        // stack clears, which is why this setTimeout is necessary
+        this.syncCursors();
+
+        // Handle scenarios where mouse used to change current position.
+        const onChangeTextEditorSelection = vscode.window.onDidChangeTextEditorSelection(
+          (e: vscode.TextEditorSelectionChangeEvent) => {
+            if (configuration.disableExt) {
+              return;
+            }

-          if (e.textEditor !== this.vimState.editor) {
-            return;
-          }
+            if (Globals.isTesting) {
+              return;
+            }

-          if (this.vimState.focusChanged) {
-            this.vimState.focusChanged = false;
-            return;
-          }
+            if (e.textEditor !== this.vimState.editor) {
+              return;
+            }

-          if (this.currentMode.name === ModeName.EasyMotionMode) {
-            return;
-          }
+            if (this.vimState.focusChanged) {
+              this.vimState.focusChanged = false;
+              return;
+            }

-          taskQueue.enqueueTask(
-            () => this.handleSelectionChange(e),
-            undefined,
-            /**
-             * We don't want these to become backlogged! If they do, we'll update
-             * the selection to an incorrect value and see a jittering cursor.
-             */
-            true
-          );
-        }
-      );
+            if (this.currentMode.name === ModeName.EasyMotionMode) {
+              return;
+            }

-      this._disposables.push(onChangeTextEditorSelection);
-      this._disposables.push(this.vimState);
+            taskQueue.enqueueTask(
+              () => this.handleSelectionChange(e),
+              undefined,
+              /**
+               * We don't want these to become backlogged! If they do, we'll update
+               * the selection to an incorrect value and see a jittering cursor.
+               */
+              true
+            );
+          }
+        );

-      cb();
-    }).catch(cb);
+        this._disposables.push(onChangeTextEditorSelection);
+        this._disposables.push(this.vimState);

+        cb();
+      })
+      .catch(cb);
  }

  /**
@@ -826,7 +827,7 @@ export class ModeHandler implements vscode.Disposable {
      if (
        recordedState.operators.length > 1 &&
        recordedState.operators.reverse()[0].constructor ===
-        recordedState.operators.reverse()[1].constructor
+          recordedState.operators.reverse()[1].constructor
      ) {
        resultVimState = await recordedState.operator.runRepeat(
          resultVimState,
@@ -1414,8 +1415,8 @@ export class ModeHandler implements vscode.Disposable {
    const easyMotionHighlightRanges =
      this.currentMode.name === ModeName.EasyMotionInputMode
        ? vimState.easyMotion.searchAction
-          .getMatches(vimState.cursorPosition, vimState)
-          .map(x => x.toRange())
+            .getMatches(vimState.cursorPosition, vimState)
+            .map(x => x.toRange())
        : [];
    this.vimState.editor.setDecorations(Decoration.EasyMotion, easyMotionHighlightRanges);

diff --git a/src/mode/modeHandlerMap.ts b/src/mode/modeHandlerMap.ts
index f45adcf..5ab2e50 100644
--- a/src/mode/modeHandlerMap.ts
+++ b/src/mode/modeHandlerMap.ts
@@ -9,7 +9,7 @@ class ModeHandlerMapImpl {
    if (!modeHandler) {
      isNew = true;
      await new Promise((res, rej) => {
-        modeHandler = new ModeHandler((err) => {
+        modeHandler = new ModeHandler(err => {
          if (err) {
            rej(err);
            return;
diff --git a/src/mode/modes.ts b/src/mode/modes.ts
index 3670c80..4bbc29a 100644
--- a/src/mode/modes.ts
+++ b/src/mode/modes.ts
@@ -66,7 +66,9 @@ export class SearchInProgressMode extends Mode {

  getStatusBarText(vimState: VimState): string {
    if (vimState.globalState.searchState === undefined) {
-      logger.error(`SearchInProgressMode.getStatusBarText: vimState.globalState.searchState is undefined.`);
+      logger.error(
+        `SearchInProgressMode.getStatusBarText: vimState.globalState.searchState is undefined.`
+      );
      return '';
    }
    const leadingChar =
Prettier Failed. Run [10:21:59] Using gulpfile ~/build/VSCodeVim/Vim/gulpfile.js
[10:21:59] Starting 'forceprettier'...
[10:22:11] Finished 'forceprettier' after 12 s and commit changes to resolve.
TravisBuddy Request Identifier: 20841290-fad3-11e8-857e-fba1c219b0f6

@jpoon jpoon merged commit 705665e into VSCodeVim:master Dec 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants