question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Highlight the active character in character-wise selections.

See original GitHub issue

When selection behavior is set to character, the VSCode cursor beam / block / underline does not reflect the fact that the cursor is on an active character instead of a position between characters.

The block cursor shape in VSCode is especially misleading since it highlights one character AFTER the active character when selection is forwards. (Backward selections are fine though.)

It’ll be great if Dance add an option to highlight the active character within the extension. In this way, users can learn to keep their eyes on that one and ignore / hide the VSCode cursor. This helps to reduce confusions like #96.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
losnappascommented, Jan 27, 2021

I did some tinkering around with the “select if nothing is selected” method, here’s what I’ve got

  {
    "key": "d",
    "command": "dance.run",
    "when": "editorTextFocus && dance.mode == 'normal'",
    "args": {
      "code": [
        "const editor = vscode.window.activeTextEditor;",
        "if (editor === undefined) return;",
        "const selection = editor.selection",
        "const nothingSelected = selection.start.line === selection.end.line && selection.start.character === selection.end.character;",
        "if (nothingSelected)",
        "return vscode.commands.executeCommand('dance.right.extend').then(() => vscode.commands.executeCommand('dance.delete.yank'))",
        "else",
        "return vscode.commands.executeCommand('dance.delete.yank')"
      ]
    }
  },
  {
    "key": "c",
    "command": "dance.run",
    "when": "editorTextFocus && dance.mode == 'normal'",
    "args": {
      "code": [
        "const editor = vscode.window.activeTextEditor;",
        "if (editor === undefined) return;",
        "const selection = editor.selection",
        "const nothingSelected = selection.start.line === selection.end.line && selection.start.character === selection.end.character;",
        "if (nothingSelected)",
        "return vscode.commands.executeCommand('dance.right.extend').then(() => vscode.commands.executeCommand('dance.delete.insert.yank'))",
        "else",
        "return vscode.commands.executeCommand('dance.delete.insert.yank')"
      ]
    }
  },
  {
    "key": "shift+k",
    "command": "dance.run",
    "when": "editorTextFocus && dance.mode == 'normal'",
    "args": {
      "code": [
        "const editor = vscode.window.activeTextEditor;",
        "if (editor === undefined) return;",
        "const selection = editor.selection",
        "const nothingSelected = selection.start.line === selection.end.line && selection.start.character === selection.end.character;",
        "if (nothingSelected)",
        "return vscode.commands.executeCommand('dance.right.extend').then(() => vscode.commands.executeCommand('dance.selections.flip')).then(() => vscode.commands.executeCommand('dance.up.extend'))",
        "else",
        "return vscode.commands.executeCommand('dance.up.extend')"
      ]
    }
  },
  {
    "key": "p",
    "command": "dance.run",
    "when": "editorTextFocus && dance.mode == 'normal'",
    "args": {
      "code": [
        "const editor = vscode.window.activeTextEditor;",
        "if (editor === undefined) return;",
        "const selection = editor.selection",
        "const nothingSelected = selection.start.line === selection.end.line && selection.start.character === selection.end.character;",
        "if (nothingSelected)",
        "return vscode.commands.executeCommand('dance.right.extend').then(() => vscode.commands.executeCommand('dance.paste.after'))",
        "else",
        "return vscode.commands.executeCommand('dance.paste.after')"
      ]
    }
  },
  {
    "key": "y",
    "command": "dance.run",
    "when": "editorTextFocus && dance.mode == 'normal'",
    "args": {
      "code": [
        "const editor = vscode.window.activeTextEditor;",
        "if (editor === undefined) return;",
        "const selection = editor.selection",
        "const nothingSelected = selection.start.line === selection.end.line && selection.start.character === selection.end.character;",
        "if (nothingSelected)",
        "return vscode.commands.executeCommand('dance.right.extend').then(() => vscode.commands.executeCommand('dance.yank'))",
        "else",
        "return vscode.commands.executeCommand('dance.yank')"
      ]
    }
  },

Put that in your keybindings.json and use the “caret mode” (not character), I think it works a bit better, haven’t gotten any issues so far, but then again I’ve only tried this for a day.

1reaction
yerlasercommented, Nov 26, 2020

Not really a solution, but rather a dirty hack: hide the cursor by making it same color as the highligh background. I made it with these lines:

“dance.normalMode.cursorStyle”: “line-thin”, “editor.cursorBlinking”: “solid”, “workbench.colorCustomizations”: { “editorCursor.foreground”: “#e7f1fa” }

The foreground color above must be found experimentally according to the color scheme used. With this I have peace in mind with the character-wise setting.

P.S. This also affects the cursor color in insert mode, but when it’s in its default “line” width it gives enough of a clue on where the insertion poit is.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Highlight text style in the Asset Panel when selecting object on ...
Solution: To be able to click one of my text-boxes and the relevant Character Style gets highlighted in the Assets window.
Read more >
Make paren highlighting consistent with evil-move-cursor-back
Another possible solution would simply be to ensure that the last character is always selected (although as an Emacs user, I'd prefer a...
Read more >
[Feature request] Notes next to your characters in the ...
Hello, I am requesting a feature that would allow you to set notes ... selection screen or on their portrait in-game and select...
Read more >
Show all highlights - Regardless of active folder - Weava
On entering a webpage (or PDF), allow the user to see all the highlights that were made on that page, but saved into...
Read more >
feature request : highlighted function - Page 2 - FreeCAD Forum
The tab is called Selection, and the option to highlight is in there. ... the last (active) operation and the whole model is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found