~reykjalin/vscode-kakoune

5 2

C-in-normal-mode-executes-insertCursorBelow

Details
Message ID
<323a2ddd-beb1-4c0f-8c59-824e6d8492ae@www.fastmail.com>
DKIM signature
missing
Download raw message
Patch: +3 -0
Hi

This patch emulates "copy the main selection to the next line" from kakoune. It is not exactly the same, but is ok for the main use-case: block comment / uncomment.

Please CC, I haven't subscribed the list.

Best,
Jean-Louis


From da56b86baee24e28cf9cc0e87ef6cab94c7cc311 Mon Sep 17 00:00:00 2001
Date: Thu, 23 Jun 2022 12:35:51 +0200
Subject: [PATCH 1/2] <C> in normal mode executes insertCursorBelow

---
 src/Extension.re | 1 +
 src/Movements.re | 1 +
 src/Vscode.re    | 1 +
 3 files changed, 3 insertions(+)

diff --git a/src/Extension.re b/src/Extension.re
index d2d59dd..3360746 100644
--- a/src/Extension.re
+++ b/src/Extension.re
@@ -116,6 +116,7 @@ let handleNormalMode =
  | "L" => Movements.extendCharacterRight()
  | "x" => Movements.selectCurrentLine()
  | "X" => Movements.expandLineSelection()
  | "C" => Movements.insertCursorBelow()
  // Goto.
  | "g" => Mode.setMode(Goto)
  | "G" => Mode.setMode(GotoExtend)
diff --git a/src/Movements.re b/src/Movements.re
index e95d8db..23c028d 100644
--- a/src/Movements.re
+++ b/src/Movements.re
@@ -47,6 +47,7 @@ let selectPreviousWord = (editor: Vscode.TextEditor.t) => {
let extendPreviousWord = () => Vscode.Commands.selectWordStartLeft();

let expandLineSelection = () => Vscode.Commands.expandLineSelection();
let insertCursorBelow = () => Vscode.Commands.insertCursorBelow();

let selectCurrentLine = () => {
  Vscode.Commands.cancelSelection();
diff --git a/src/Vscode.re b/src/Vscode.re
index 528120f..3c839ed 100644
--- a/src/Vscode.re
+++ b/src/Vscode.re
@@ -118,6 +118,7 @@ module Commands = {

  let cancelSelection = () => "cancelSelection" |> executeCommand;
  let expandLineSelection = () => "expandLineSelection" |> executeCommand;
  let insertCursorBelow = () => "editor.action.insertCursorBelow" |> executeCommand;

  let moveCharacterRight = () => "cursorRight" |> executeCommand;
  let selectCharacterRight = () => "cursorRightSelect" |> executeCommand;
-- 
2.25.1
Details
Message ID
<03A8123A-DD2F-4DD5-8E4C-932C439A9B53@thorlaksson.com>
In-Reply-To
<323a2ddd-beb1-4c0f-8c59-824e6d8492ae@www.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
Hi Jean-Louis, thank you for the patch!

I haven’t worked on the extension in a really long time so and couldn’t build
the project without making some really major updates to the build tooling.
Unfortunately I seem to have introduced some bugs in the process.

I’ve applied your patch, but I’m not going to release a new version of the
extension until I fix the bugs. Hopefully a new version will be out in the next
couple of days, but it really depends on how much time I have to work on this.

Thank you for the interest! I’ll get a new release out as soon as I have the
time.


If you’re interested in taking a look yourself, the bug is in the t/T and f/F
(extend until/move to character) functions. Probably just some incorrect array
or list usage, but I’ll need some time to take a look.
There’s also a problem with the selections made by h/j/k/l which, again, is
probably incorrect array/list usage.


-Kristófer R.
Details
Message ID
<805aedb3-96f4-4cc9-b3b4-b743db838b5c@www.fastmail.com>
In-Reply-To
<03A8123A-DD2F-4DD5-8E4C-932C439A9B53@thorlaksson.com> (view parent)
DKIM signature
missing
Download raw message
Hi Kristófer

On Fri, 24 Jun 2022, at 10:45, Kristofer Reykjalin wrote:


> I haven’t worked on the extension in a really long time so and couldn’t build
> the project without making some really major updates to the build tooling.
> Unfortunately I seem to have introduced some bugs in the process.
>
> I’ve applied your patch, but I’m not going to release a new version of the
> extension until I fix the bugs. Hopefully a new version will be out in the next
> couple of days, but it really depends on how much time I have to work on this.

Interesting, my build didn't introduce the bug. I called:

npm install
npm run build
npm run webpack

I don't know the javascript eco-system well.

> Thank you for the interest! I’ll get a new release out as soon as I have the
> time.

Thanks a lot for the great extension. Take your time.

Best,
Jean-Louis
Details
Message ID
<325E08AA-2997-4598-A032-931C1A5FF31A@thorlaksson.com>
In-Reply-To
<805aedb3-96f4-4cc9-b3b4-b743db838b5c@www.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
Hi again Jean-Louis!

> Interesting, my build didn't introduce the bug. I called:
> 
> npm install
> npm run build
> npm run webpack

Ah no, sorry for the confusion. I had to remove an old dependency and updating
the code to compensate for losing that dependency introduced the bug. I had to
remove the dependency because I got some error when I tried to run
`npm install`. In any case, updating the build tooling should be a net benefit I
think, so it was worthwhile to go through that :)

> Thanks a lot for the great extension. Take your time.

You’re very welcome! I’m happy it’s useful for someone :)
I’ve just published v1.3.0 of the extension with the new `C` command you
contributed included!

Let me know if you run into any issues and I’ll patch it and do another release
if I broke something!


Best regards,
-Kristófer R.
Details
Message ID
<62b05d1a-9988-4a16-aa65-e26ec1549ae0@www.fastmail.com>
In-Reply-To
<325E08AA-2997-4598-A032-931C1A5FF31A@thorlaksson.com> (view parent)
DKIM signature
missing
Download raw message
Hi Kristofer

On Sat, 25 Jun 2022, at 05:33, Kristofer Reykjalin wrote:

> You’re very welcome! I’m happy it’s useful for someone :)
> I’ve just published v1.3.0 of the extension with the new `C` command you
> contributed included!

Thanks you very much.

> Let me know if you run into any issues and I’ll patch it and do another release
> if I broke something!

As far as I know it works as expected, but in normal mode the cursor doesn't turn
into a block anymore.

Best,
Jean-Louis
Details
Message ID
<B28EC159-9D4A-48AD-920B-01366499BBB4@thorlaksson.com>
In-Reply-To
<62b05d1a-9988-4a16-aa65-e26ec1549ae0@www.fastmail.com> (view parent)
DKIM signature
missing
Download raw message
Hi Jean-Louis

> As far as I know it works as expected, but in normal mode the cursor doesn't turn
> into a block anymore.

Ah, you’re right! I didn’t notice that, thanks for letting me know!

I’ve just published version 1.3.1 to correct this :)


-Kristófer R.
Reply to thread Export thread (mbox)