From 51de941f79db0032331cfb26e7f00947cae992e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E9=9B=85=20=C2=B7=20Misaki=20Masa?= Date: Tue, 4 Mar 2025 22:21:04 +0800 Subject: [PATCH] feat: new `` and `` keybindings to select entire line for the input component (#2439) --- .github/workflows/draft.yml | 52 +++++++++++++------------- yazi-config/preset/keymap-default.toml | 6 ++- yazi-core/src/input/commands/visual.rs | 15 ++++---- yazi-fm/src/executor.rs | 2 + 4 files changed, 40 insertions(+), 35 deletions(-) diff --git a/.github/workflows/draft.yml b/.github/workflows/draft.yml index e863eeb0..b2ab958d 100644 --- a/.github/workflows/draft.yml +++ b/.github/workflows/draft.yml @@ -176,6 +176,32 @@ jobs: name: yazi-${{ matrix.arch }}.snap path: yazi-${{ matrix.arch }}.snap + snap: + runs-on: ubuntu-latest + needs: [build-snap] + steps: + - uses: actions/download-artifact@v4 + with: + pattern: yazi-*.snap + merge-multiple: true + + - name: Setup snapcraft + run: sudo snap install --classic snapcraft + + - name: Push snap to candidate channel + if: startsWith(github.ref, 'refs/tags/') + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} + run: | + parallel 'snapcraft push -v --release latest/candidate {}' ::: yazi-*.snap + + - name: Push snap to edge channel + if: ${{ !startsWith(github.ref, 'refs/tags/') }} + env: + SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} + run: | + parallel 'snapcraft push -v --release latest/edge {}' ::: yazi-*.snap + draft: if: startsWith(github.ref, 'refs/tags/') permissions: @@ -232,29 +258,3 @@ jobs: name: Nightly Build body: ${{ env.NIGHTLY_BODY }} target_commitish: ${{ github.sha }} - - snap: - runs-on: ubuntu-latest - needs: [build-snap] - steps: - - uses: actions/download-artifact@v4 - with: - pattern: yazi-*.snap - merge-multiple: true - - - name: Setup snapcraft - run: sudo snap install --classic snapcraft - - - name: Push snap to candidate channel - if: startsWith(github.ref, 'refs/tags/') - env: - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} - run: | - parallel 'snapcraft push -v --release latest/candidate {}' ::: yazi-*.snap - - - name: Push snap to edge channel - if: ${{ !startsWith(github.ref, 'refs/tags/') }} - env: - SNAPCRAFT_STORE_CREDENTIALS: ${{ secrets.SNAPCRAFT_TOKEN }} - run: | - parallel 'snapcraft push -v --release latest/edge {}' ::: yazi-*.snap diff --git a/yazi-config/preset/keymap-default.toml b/yazi-config/preset/keymap-default.toml index 8dcf4601..6dadcbaa 100644 --- a/yazi-config/preset/keymap-default.toml +++ b/yazi-config/preset/keymap-default.toml @@ -237,9 +237,13 @@ keymap = [ { on = "a", run = "insert --append", desc = "Enter append mode" }, { on = "A", run = [ "move eol", "insert --append" ], desc = "Move to the EOL, and enter append mode" }, { on = "v", run = "visual", desc = "Enter visual mode" }, - { on = "V", run = [ "move bol", "visual", "move eol" ], desc = "Enter visual mode and select all" }, { on = "r", run = "replace", desc = "Replace a single character" }, + # Selection + { on = "V", run = [ "move bol", "visual", "move eol" ], desc = "Select from BOL to EOL" }, + { on = "", run = [ "move eol", "visual", "move bol" ], desc = "Select from EOL to BOL" }, + { on = "", run = [ "move bol", "visual", "move eol" ], desc = "Select from BOL to EOL" }, + # Character-wise movement { on = "h", run = "move -1", desc = "Move back a character" }, { on = "l", run = "move 1", desc = "Move forward a character" }, diff --git a/yazi-core/src/input/commands/visual.rs b/yazi-core/src/input/commands/visual.rs index 120cff8a..4dd1ca5d 100644 --- a/yazi-core/src/input/commands/visual.rs +++ b/yazi-core/src/input/commands/visual.rs @@ -4,16 +4,15 @@ use yazi_shared::event::CmdCow; use crate::input::{Input, InputMode, op::InputOp}; impl Input { - #[inline] pub fn visual(&mut self, _: CmdCow) { - let snap = self.snap_mut(); - if snap.mode != InputMode::Normal { - return; - } else if snap.value.is_empty() { - return; + if self.snap().mode != InputMode::Normal { + self.escape(()); } - snap.op = InputOp::Select(snap.cursor); - render!(); + let snap = self.snap_mut(); + if !snap.value.is_empty() { + snap.op = InputOp::Select(snap.cursor); + render!(); + } } } diff --git a/yazi-fm/src/executor.rs b/yazi-fm/src/executor.rs index aef7b93f..a5a21700 100644 --- a/yazi-fm/src/executor.rs +++ b/yazi-fm/src/executor.rs @@ -277,6 +277,8 @@ impl<'a> Executor<'a> { } } InputMode::Insert => { + on!(visual); + on!(backspace); on!(kill); }