Giter VIP home page Giter VIP logo

dance's People

Contributors

71 avatar avi-d-coder avatar blefevre avatar delapouite avatar dependabot[bot] avatar geier1993 avatar gouegd avatar jjk96 avatar kabouzeid avatar petertheprocess avatar strackeror avatar stuarth avatar thejoeschr avatar tshort avatar yuchenshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dance's Issues

`N` and `a+N` stop after selecting two matches

To reproduce:

  1. Open a file with enough text to search.
  2. Hit / and type a search phrase. The cursor jumps to the location on screen.
  3. Hit N. The next hit will be selected.
  4. Hit N again, nothing happens.

Behavior of `j`/`J`

Thanks for publishing the extension to the marketplace, it's working great!

One thing I noticed is that the behavior of j/J seems to have changed from regular Kakoune. As far as I can tell, in regular Kakoune j acts similar to the arrow key: it only performs movements, while J can be used to extend a selection.

In dance j extends the selection, where as J goes into insert mode. Is this intentional, or maybe something that I can configure?

Build fails

I try to build the plugin with

vsce package
Executing prepublish script 'npm run vscode:prepublish'...
 ERROR  Command failed: npm run vscode:prepublish
warning [email protected]: The engine "vscode" appears to be invalid.
/bin/sh: ts-node: command not found
error Command failed with exit code 127.
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] vscode:prepublish: `yarn run generate && yarn run compile`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] vscode:prepublish script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/jjk/.npm/_logs/2019-06-17T12_21_36_192Z-debug.log

Any ideas on what might be the problem?

Cursor moves out of visible window area

Thank you very much for making this and putting it on the marketplace!

I've found that when in normal mode, moving the cursor off the top or bottom of the window does not cause the window to scroll.

To reproduce:

  1. Have enough text in the file that the bottom of the file cannot be seen
  2. Be in normal mode (not insert mode)
  3. Keep pressing j until the cursor moves below the last visible line
  4. Observe that the window does not scroll, and the cursor is no longer visible

The same applies when the top of the file is not visible and I move the cursor to the start of the file using gg.

I've disabled all extensions except Dance.

I've observed the issue on Linux and Windows.

Version info (Linux):

Dance: 0.1.4
Ubuntu 18.04.2 LTS
VSCode:
Version: 1.39.2
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:33:40.634Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 4.15.0-70-generic

Thank you, and let me know if there's any other info I can provide etc.!

Selections are forgotten when entering insert mode

Kakoune keeps track of selections when entering insert mode, Dance doesn't. To reproduce:

  1. Select a word hello
  2. Hit i to enter insert mode
  3. Do some edits
  4. Hit escape to exit insert mode

Expected output:

  • Old selection is restored.

Actual output:

  • There is no selection any more.

(When hitting a instead of i, the selection gets extended with the entered text.)

I'm not entirely sure if implementing this matches the philosophy that "Dance's only goal is to provide VS Code-native commands and key bindings that are inspired by Kakoune" or not. My use case was adding quotes around every selection. Maybe there is a better way to do this.

Option keys not usable as mappings on macOS

On macOS the alt/option key is used as a second shift like key: one can enter special characters as ∂, ƒ, ¬, ø (option+d, option+f, option+l, option+o). Problematic are the keys option+\``, option+e, option+u, option+i, option+n which are dead keys to compose diacritics like è, é, ë, ê and ñ. These can't be used to map Kakoune/Dance chords.

This solution only adds support to use option as meta in the terminal emulator of VSCode. Using something like this in the editor is currently not supported and should probably be fixed in core VSCode.

`<i-w>` does not work correctly on last word of line

To reproduce:

  1. Place cursor on last word of line
  2. Hit <i-w>

Expected output:

  • Last word gets selected

Actual output:

  • Just current character gets selected

This happens in the new single char selection mode as well as the empty selection mode.

`d` with no selection does not delete a character

Correct me if I'm wrong - I'm very new to kakoune-style bindings, but I thought d without explicitly selecting anything should delete the character under the cursor. Dance doesn't seem to do that.

Implement Ctrl+U, Ctrl+D keybindings

Currently I use this in my keybindings.json

{
    "key": "ctrl+u",
    "command": "cursorMove",
    "args": {
      "to": "up",
      "by": "line",
      "value": 20
    },
    "when": "editorTextFocus && dance.mode == 'normal'"
  },
  {
    "key": "ctrl+d",
    "command": "cursorMove",
    "args": {
      "to": "down",
      "by": "line",
      "value": 20
    },
    "when": "editorTextFocus && dance.mode == 'normal'"
  },

Maybe it should be default ?

Relative line numbers persist when Dance turned off

To reproduce run the Dance: toggle command from either normal or insert mode.

Expected behaviour: Line numbering reverts to the editor.lineNumbers setting.

Actual behaviour: Line numbering stays as relative (if toggled from normal mode) or switch back to relative (if toggled from insert mode)

Split lines command doesn't select intermediate lines above cursor.

I noticed some strange behavior when trying to use the dance.split.lines command (Alt+S):

If you have the cursor at the end of the selection it looks like it works as intended:

image
image

But if you put it at the beginning you get this weird behavior where only the first and last line are selected:

image
image

Assuming this is unintended behavior, I think the issue is probably with this bit of code:

// Add intermediate lines
for (let i = selection.anchor.line + 1; i < selection.active.line; i++) {
const selectionRange = editor.document.lineAt(i).range
newSelections.push(new vscode.Selection(selectionRange.start, selectionRange.end))
}
}

Visual cue to distinguish modes

In vanilla Kakoune and also in Dance I tend to mix up which mode I'm in. I know the status bar shows me "Normal" or "Insert", but it is usually far away from the cursor, where my eyes are, and I have to search for the text between all the other information VSCode shows in the status bar.

I love how in Vim you can spot the difference just by looking at the cursor: a block for normal mode, and a line for insert mode. However, this is not an option for Dance, because of the (very well founded!) choice to support zero width selections.

I was thinking about other ways to visually distinguish normal mode and insert mode. Till now, I've come up with two ideas:

  • Change the way the current line is highlighted:
    • while in insert mode highlight it: "editor.renderLineHighlight": "line"
    • while in normal mode remove the highlighting: "editor.renderLineHighlight": "none"
  • Change the color of the status bar (don't know if this is easily doable).

What do you think of these options?

Changing line numbers to 'on' or 'relative' messes up decorations

The lineNumbers setting is changed on each mode changed; on if in insert mode, or relative if in normal mode. This seems to cause problems with decorations that don't get removed even though they should.

To reproduce:

  • Install Trailing Spaces.
  • Go to the beginning of a line.
  • Insert some spaces, then some text.
  • Go back to normal mode.
  • Press o to insert a new line and go back to insert mode. All text that will be written will be incorrectly shown in red highlight, as if it was trailing whitespace.

I don't know yet if this is a problem with Dance, with Trailing Spaces, or with VS Code itself.

Some option keybindings broken on macOS

Typing Option+e, Option+i, Option+u, Option+n, and maybe some other keys on macOS will wait for the next character and put some diacritic mark on it (acute, circumflex, umlaut and tilde respectively). When using kakoune keybindings that are bound to these keys in vscode, such as the OS will insert the diacritic mark before Dance gets invoked, and this makes those keybindings unusable.

`{` chord does not select braces consistently

To reproduce:

  1. Create a new document and type {a}.
  2. Put the cursor after the a.
  3. Hit alt+a { to select including the braces.

Expected output:

  • {a} should be selected

Observed output:

  • only {a is selected

The same thing happens when braces are put on a newline or different types of braces are used.

`C` and `alt-C` should copy selections

Sorry to bother you again 😉 . In regular Kakoune you can use C (shift-c) and alt-C (alt-shift-c) to copy selections to the following/previous line, which creates a multi-cursor.

Key Description ALT + key CTRL + key g key (goto)
C copy selection on next lines copy selection on previous lines    

Would it be possible to add this command too? Thanks!

multiple selection yank

In dance deleting and pasting :

1
2
3

produce:

1
1
1

However in vscode multiple selection and kakoune :

1
2
3

is restored.

Feature Request: Saving/Restoring Selections

How can I access the position of the last change?

In vscodevim it is implemented like:

// src/actions/commands/actions.ts
@RegisterAction
class CommandGoLastChange extends BaseCommand {
  modes = [ModeName.Normal];
  keys = [['`', '.'], ["'", '.']];
  isJump = true;

  public async exec(position: Position, vimState: VimState): Promise<VimState> {
    const lastPos = vimState.historyTracker.getLastHistoryStartPosition();

    if (lastPos !== undefined) {
      vimState.cursorStopPosition = lastPos[0];
    }

    return vimState;
  }
}

and

// src/history/historyTracker.ts

  /**
   * Gets the ending cursor position of the last Change of the last Step.
   *
   * In practice, this sets the cursor position to the end of
   * the most recent text change.
   */
  getLastChangeEndPosition(): Position | undefined {
    if (this.currentHistoryStepIndex === 0) {
      return undefined;
    }
    const lastChangeIndex = this.historySteps[this.currentHistoryStepIndex].changes.length;
    if (lastChangeIndex === 0) {
      return undefined;
    }
    return this.historySteps[this.currentHistoryStepIndex].changes[lastChangeIndex - 1].end();
  }

  getLastHistoryStartPosition(): Position[] | undefined {
    if (this.currentHistoryStepIndex === 0) {
      return undefined;
    }

    return this.historySteps[this.currentHistoryStepIndex].cursorStart;
  }

So there are two things needed a VimState and a HistoryTracker.
Is there already something like a state that stores information about the extension independent of the document? (I'm not experienced with vscode extensions yet).

And I guess that we have to adapt the HistoryTracker, also to implement Goto previous buffer and Goto File.

`*` takes selection as regex

To reproduce:

  1. Select some text containing special regex chars.
  2. Hit *.
  3. Hit n.

Expected output:

  • Next occurrence of text will be highlighted.

Actual output:

  • Probably nothing happens because the selected text is interpreted as a regex.

Proposed solution:

  • Escape special characters when using *.

9w selects 9 words rather than the 9th word

In kakoune, 9w (lower case w) moves forward by 9 words, selecting the 9th word. However, in dance it will select from current active to 9 words later, for a total selection of 9 words (as if 9W with Shift+W were used).

Is this something worth fixing? I can draft a PR for this.

Desired columns are not set after commands

Hey there! In VSCodeVim we keep track of the column that the cursor wants to be on in addition to the one it's actually on (VimState.desiredColumn). So $ will set the desired column to MAX_INT - that way, motions like j and k will go to the end of the line, when coming from a shorter line.

It does seem dance has that concept, but gh and gl don't set it to 0 and MAX_INT like kakoune does.

(Very cool extension, by the way! I'll definitely try to find some time to contribute)

Linewise operations

I'd like to start a discussion about linewise operations.

Linewise yank/delete and paste

Currently, when you yank/delete some lines (technically: text which happens to end with a newline char), and you'd like to paste it, three things can happen, depending on the position of your cursor in a line. In all cases, when your selection is empty, hitting p or P doesn't make a difference:

  • When your cursor is at the begin of line, the text is pasted before the current line, on a new line.
  • When your cursor is at the end of a line, the text is pasted after the current line, on the same line, with a newline at the end.
  • When your cursor is in the middle of a line, the text is pasted at that point, including indentation and with a newline at the end.

This seems all very logical, if you think about the shape of the selection you yanked/deleted and compare this to a contemporary text editor when you're using ctrl+c/x and ctrl+v.

However, coming from Vim, this is strange behaviour. What you probably want to achieve, is yank/delete and paste text linewise. I.e. in Vim, yanking/deleting some lines with yy/dd, and then pasting it somewhere does (at least for me) the sensible thing:

  • Hitting P pastes the lines before the current line.
  • Hitting p pastes the lines after the current line.

All without mingling with the line the cursor is on.

The developers of Kakoune acknowledged this issue, and altered the behaviour of paste likewise, depending on the pasted text ending in a newline or not. I think we should do this as well.

Linewise change

Then, I think there is at least one more case where linewise operations come at hand: the equivalent of Vim's change line command cc. For example, if you hit 2Xc, Kakoune deletes 2 lines including the line end and starts insert mode at column 0 with the contents of the next line after the cursor. I find this particularly annoying for a couple of reasons:

  • Kakoune does not take into account the indentation of the surrounding lines.
  • The line I’m editing is polluted with the contents of the next line which moves along when I type.
  • I have to hit return after my changes to re-enter the end of line which was deleted.

This happens because the current behaviour of c is equivalent to di. However, when the selected text ends with a newline, the sensible thing (again, in my opinion and also what Vim does) would be that c executes dO: delete+yank the selected lines and open a new line in insert mode with the correct indentation without joining in text from the next line.

Maybe more?

I'm curious what you think about these mechanics. I found this a serious flaw of Kakoune. Maybe there are more instances of linewise operations that I didn't think of yet, but I think yy, dd and cc from Vim are the most apparent.

Implementation wise this would not be a difficult thing to do, I think. Just check if the line in the register or the currently selection ends with a newline character.

Discoverability on Marketplace

First, I have to say how super awesome I find this plugin! It is exactly what I was looking for. Wanted to have this for a long time. Combines best of all the worlds of VSCode and Kakoune and Vim :-)

Took me some time to find this plugin however. Think adding the word "Kakoune" to the description will make the plugin way more discoverable on the marketplace!

Some keybindings are incorrectly generated

Some keybindings are set to unknown by VSCode. This probably has to do something with the generate script and the yaml source.

Till now I've found these keys do not work out of the box (including their alt-counterparts):

  • Search and friends (/, ?)
  • Objects and friends ([, ], {, })
  • Indentation (<, >)

Add git tags to the version bump commits

It would be nice to have easy access to the list of versions. The releases don't have to be published on GitHub, but just creating the tags would already populate the listing at https://github.com/71/dance/releases (example).

For convenience, here's the list of releases so far:

(If you're feeling generous, a CHANGELOG.md file would be nice as well!)

`n` after using `N` forgets selection

To reproduce:

  1. Open a document with some repetitive word and search for it.
  2. To select a couple of occurrences, use N a couple of times.
  3. To skip an occurrence, hit n

Expected outcome:

  • All previous selections remain
  • The last selection is skipped
  • The next match is selected

Actual outcome:

  • All previous selections are cleared

Behaviour of `a+x` depends on position of cursor in selection

To reproduce:

  1. Open a new document and type
    [
      {
        a
      }
    ]
    
  2. Put the cursor after {.
  3. Hit alt+a { to select including the braces.
  4. Hit alt+x to extend lines.

Expected output:

  • Lines 2–4 are selected, including line ends.

Actual output:

  • Only line 3 is selected.

When performing instead:
3. Hit alt+; to swap the position of the cursor.
4. Hit alt+x to extend lines.

Everything works fine.

`.` replays insert keys without backspace

Using . replays all insert keys but does not take care of any corrections made during insertion and of auto inserted parens/brackets.

To reproduce:

  1. Hit i and type funk<backspace>c(arg) and hit <escape>
  2. Hit . to repeat the command.

Expected output:
func(arg)

Actual output:
funkc()arg)

Cursor style not set on startup

0.2.0 is awesome! Thanks for all the work on single char selections and the customisation options added. There are a few small bugs however. I'll fill in separate issues.

The Normal Mode: Cursor Style option is not respected when starting VSCode. I.e. the default cursor is rendered instead. After entering insert mode and normal mode again, it works correct.

`e` selects newline

Moving with e over the last word on a line should not select the newline but end at the words end.

Search does not wrap

Using / at the end of file does not wrap around. (Likewise for a-/ at begin of file.)

Cursor gets stuck at end of document

It seems like the cursor can get 'stuck' at the end of a document while in normal mode. I don't know exactly what triggers it; it only seems to happen sometimes.

Here's a set of steps to reproduce. It's a bit of a strange sequence but it was the minimal set of steps I could find.

  1. Open a new document, and do the following key presses:
  2. i (enter insert mode)
  3. a
  4. Enter (document should now be 'a' followed by an empty line)
  5. Esc (back to normal mode)
  6. k (cursor is now at the start of the document)
  7. k (even though the cursor is already at the start of the document, this seems to be necessary)
  8. j
  9. j (cursor is now at the end of the document)
  10. k

This last k doesn't move the cursor up, and it is now 'stuck'. If the cursor becomes stuck on a line that does contain text, it can't be moved left with h either.

Entering insert mode or jumping (e.g., gg) makes the cursor 'unstuck' and free to move again.

Thanks again!

Dance: 0.1.4
Ubuntu 18.04.2 LTS
VSCode:
Version: 1.39.2
Commit: 6ab598523be7a800d7f3eb4d92d7ab9a66069390
Date: 2019-10-15T15:33:40.634Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Linux x64 4.15.0-70-generic

Extend goto keys

Is there an easy way to add new key bindings under the goto subspace? Adding something like this:

{
    "key": "g n",
    "command": "editor.action.marker.next",
    "when": "editorTextFocus && dance.mode == 'normal'"
},

will render all existing goto bindings useless.

Unable to listen to keyboard events

Some commands result in an error:

Unable to listen to keyboard events; is an extension overriding the "type" command (e.g VSCodeVim)?

Known commands with this behaviour:

  • dance.register.select
  • dance.replace.characters

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.