Comments (3)
I'm disagreeing that this is a good first issue, it cuts to a fundamental issue with vi-mode: The cursor placement isn't the same as in emacs mode.
That needs some careful consideration, because it would probably touch a lot more than the one bind function.
See also #8189 or #3005, which both mention it as an issue with $
, and #3006, which tried to fix it exclusively for $
.
I'm going to close both of those and leave the issue at hand to be tracked here.
from fish-shell.
Until this gets fixed fundamentally, is there any intermediary fish script conditional hack that could fix this specific pattern (normal mode forward-char
accepting suggestions behavior)? Or are the apis necessary just not available?
from fish-shell.
It's not worth to add a hack.
Better change Vi mode to always put the cursor on a character (except maybe if the commandline is empty).
We can start from this and fix any remaining issues.
diff --git a/src/reader.rs b/src/reader.rs
index 45dbe69fd..5fd0425c1 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -1181,13 +1181,26 @@ impl ReaderData {
}
/// Update the cursor position.
- fn update_buff_pos(&mut self, elt: EditableLineTag, new_pos: Option<usize>) {
- if let Some(pos) = new_pos {
+ fn update_buff_pos(&mut self, elt: EditableLineTag, new_pos: Option<usize>) -> bool {
+ if let Some(mut pos) = new_pos {
+ if self
+ .vars()
+ .get_unless_empty(L!("fish_cursor_selection_mode"))
+ .is_some_and(|mode| mode.as_list()[0] == "inclusive")
+ {
+ let el = self.edit_line(elt);
+ if !el.is_empty() && pos == el.len() {
+ pos = el.len() - 1;
+ if el.position() == pos {
+ return false;
+ }
+ }
+ }
self.edit_line_mut(elt).set_position(pos);
}
if elt != EditableLineTag::Commandline {
- return;
+ return true;
}
let buff_pos = self.command_line.position();
let target_char = if self.cursor_selection_mode == CursorSelectionMode::Inclusive {
@@ -1196,7 +1209,7 @@ impl ReaderData {
0
};
let Some(selection) = self.selection.as_mut() else {
- return;
+ return true;
};
if selection.begin <= buff_pos {
selection.start = selection.begin;
@@ -1205,6 +1218,7 @@ impl ReaderData {
selection.start = buff_pos;
selection.stop = selection.begin + target_char;
}
+ true
}
}
@@ -2240,7 +2254,9 @@ impl ReaderData {
}
position
};
- self.update_buff_pos(self.active_edit_line_tag(), Some(position + 1));
+ if !self.update_buff_pos(self.active_edit_line_tag(), Some(position + 1)) {
+ break;
+ }
},
rl::BeginningOfBuffer => {
self.update_buff_pos(EditableLineTag::Commandline, Some(0));
@@ -2644,9 +2660,9 @@ impl ReaderData {
let (elt, el) = self.active_edit_line();
if self.is_navigating_pager_contents() {
self.select_completion_in_direction(SelectionMotion::East, false);
- } else if el.position() != el.len() {
- self.update_buff_pos(elt, Some(el.position() + 1));
- } else {
+ } else if el.position() == el.len()
+ || !self.update_buff_pos(elt, Some(el.position() + 1))
+ {
self.accept_autosuggestion(
/*full=*/ c != rl::ForwardSingleChar,
/*single=*/ c == rl::ForwardSingleChar,
from fish-shell.
Related Issues (20)
- Automatically quote URLs pasted to shell HOT 1
- Fish is not very usable within "win" dumb terminal emulator of Acme text editor HOT 2
- goood HOT 1
- SIGSEGV when running an executable with non-existent dynamic interpreter HOT 2
- No bind mode for search fields, and no way to make forward-char move the cursor HOT 10
- Make # path component char HOT 1
- Shell environment can't detect current directory being removed and recreated HOT 2
- builtin commands ignore redirects when printing man pages
- alias vi to neovide and something unexpected will happen. HOT 2
- fish as login shell prevents NoMachine from running HOT 6
- no documentation for `argparse --exclusive` HOT 1
- `history delete` cannot delete last entry in list HOT 2
- Autosuggestions are sometimes not offered after recalling a previous line from history HOT 1
- Pager selection issues
- How to replace multi-line string variable in shell script HOT 2
- Inserting clipboard using OSC 52 HOT 12
- Local function definition? HOT 2
- Fish autocomplete sometimes forgets history and goes back in time HOT 17
- feature: prompt_pwd function support hyperlinks HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fish-shell.