mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-05-22 03:51:15 -03:00
commandline --cursor: respect transient command line
We have logic to prevent "commandline --cursor 123" inside "complete
-C" from setting the transient commandline's cursor.
But reading this cursor ("commandline --cursor")
is fine and expected to work by completion scripts.
I don't expect there is a use case for setting the cursor while
computing completions, so let's make that an error for now.
Could revisit that.
Closes #11993
This commit is contained in:
@@ -32,6 +32,7 @@ Deprecations and removed features
|
||||
Scripting improvements
|
||||
----------------------
|
||||
- New :ref:`status language <status-language>` commands allow showing and modifying language settings for fish messages without having to modify environment variables.
|
||||
- When using a noninteractive fish instance to compute completions, ``commandline --cursor`` no works as expected instead of throwing an error (:issue:`11993`).
|
||||
|
||||
Interactive improvements
|
||||
------------------------
|
||||
|
||||
4
po/de.po
4
po/de.po
@@ -767,6 +767,10 @@ msgstr "%s: realpath fehlgeschlagen: %s\n"
|
||||
msgid "%s: scope can be only one of: universal function global local\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: setting cursor while evaluating 'complete --arguments' is not yet supported"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: stdin is closed\n"
|
||||
msgstr "%s: stdin ist geschlossen\n"
|
||||
|
||||
4
po/en.po
4
po/en.po
@@ -765,6 +765,10 @@ msgstr ""
|
||||
msgid "%s: scope can be only one of: universal function global local\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: setting cursor while evaluating 'complete --arguments' is not yet supported"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: stdin is closed\n"
|
||||
msgstr ""
|
||||
|
||||
4
po/fr.po
4
po/fr.po
@@ -896,6 +896,10 @@ msgstr ""
|
||||
msgid "%s: scope can be only one of: universal function global local\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: setting cursor while evaluating 'complete --arguments' is not yet supported"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: stdin is closed\n"
|
||||
msgstr ""
|
||||
|
||||
4
po/pl.po
4
po/pl.po
@@ -761,6 +761,10 @@ msgstr ""
|
||||
msgid "%s: scope can be only one of: universal function global local\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: setting cursor while evaluating 'complete --arguments' is not yet supported"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: stdin is closed\n"
|
||||
msgstr ""
|
||||
|
||||
@@ -766,6 +766,10 @@ msgstr ""
|
||||
msgid "%s: scope can be only one of: universal function global local\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: setting cursor while evaluating 'complete --arguments' is not yet supported"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: stdin is closed\n"
|
||||
msgstr ""
|
||||
|
||||
4
po/sv.po
4
po/sv.po
@@ -762,6 +762,10 @@ msgstr ""
|
||||
msgid "%s: scope can be only one of: universal function global local\n"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: setting cursor while evaluating 'complete --arguments' is not yet supported"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: stdin is closed\n"
|
||||
msgstr ""
|
||||
|
||||
@@ -788,6 +788,10 @@ msgstr "%s: realpath 失败:%s\n"
|
||||
msgid "%s: scope can be only one of: universal function global local\n"
|
||||
msgstr "%s: 范围只能是:universal(通用)function(函数)global(全局)local(局域)\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: setting cursor while evaluating 'complete --arguments' is not yet supported"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: stdin is closed\n"
|
||||
msgstr "%s: stdin 已关闭\n"
|
||||
|
||||
@@ -761,6 +761,10 @@ msgstr "%s:realpath 失敗:%s\n"
|
||||
msgid "%s: scope can be only one of: universal function global local\n"
|
||||
msgstr "%s:作用域只能是以下之一:universal、function、global、local\n"
|
||||
|
||||
#, c-format
|
||||
msgid "%s: setting cursor while evaluating 'complete --arguments' is not yet supported"
|
||||
msgstr ""
|
||||
|
||||
#, c-format
|
||||
msgid "%s: stdin is closed\n"
|
||||
msgstr "%s:stdin 已關閉\n"
|
||||
|
||||
@@ -616,8 +616,7 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
|
||||
|
||||
// At this point we have (nearly) exhausted the options which always operate on the true command
|
||||
// line. Now we respect the possibility of a transient command line due to evaluating a wrapped
|
||||
// completion. Don't do this in cursor_mode: it makes no sense to move the cursor based on a
|
||||
// transient commandline.
|
||||
// completion.
|
||||
let current_buffer;
|
||||
let current_cursor_pos;
|
||||
let transient;
|
||||
@@ -632,7 +631,15 @@ pub fn commandline(parser: &Parser, streams: &mut IoStreams, args: &mut [&wstr])
|
||||
} else if let Some(override_buffer) = &override_buffer {
|
||||
current_buffer = override_buffer;
|
||||
current_cursor_pos = current_buffer.len();
|
||||
} else if parser.libdata().transient_commandline.is_some() && !cursor_mode {
|
||||
} else if parser.libdata().transient_commandline.is_some() {
|
||||
if cursor_mode && positional_args != 0 {
|
||||
streams.err.append(wgettext_fmt!(
|
||||
"%s: setting cursor while evaluating 'complete --arguments' is not yet supported",
|
||||
cmd
|
||||
));
|
||||
builtin_print_error_trailer(parser, streams.err, cmd);
|
||||
return Err(STATUS_CMD_ERROR);
|
||||
}
|
||||
transient = parser.libdata().transient_commandline.clone().unwrap();
|
||||
current_buffer = &transient;
|
||||
current_cursor_pos = transient.len();
|
||||
|
||||
@@ -686,3 +686,8 @@ complete somewrapper3
|
||||
# CHECK: complete somewrapper3
|
||||
# CHECK: complete somewrapper3
|
||||
# CHECK: complete somewrapper3 --wraps wrapped1
|
||||
|
||||
complete command-line-aware-completions -xa "(commandline --cursor; commandline --current-process)"
|
||||
complete -C"command-line-aware-completions "
|
||||
# CHECK: 31
|
||||
# CHECK: command-line-aware-completions
|
||||
|
||||
Reference in New Issue
Block a user