Skip to content

Only use list to specify editor's arguments (issue 10205) - #10210

Closed
horasal wants to merge 7 commits into
nushell:mainfrom
horasal:editor_variable
Closed

horasal wants to merge 7 commits into
nushell:mainfrom
horasal:editor_variable

Conversation

@horasal

@horasal horasal commented Sep 4, 2023 •

Copy link
Copy Markdown
Contributor

fixes #10205 without break #8051 as possible

Description

While dealing with #8051 , the function for using arguments in editor variable is introduced but it still only receive string for $env.VISUAL and $env.EDITOR so the input is just splitted by ' ' to find arguments, and this finally causes #10205.

As nushell provides list<string>, it's more natural to use a list rather than string for list of arguments.

User-Facing Changes

  • $env.EDITOR = "string" is only considered as an executable
  • User should use $env.EDITOR = ["editor", "-argument"] to specify arguments

Tests + Formatting

  • 🟢 toolkit fmt
  • 🟢 toolkit clippy
  • 🟢 toolkit test
  • 🟢 toolkit test stdlib

After Submitting

Add what is allowed for these variables in https://nushell.sh/book/configuration.html#configurations-with-built-in-commands

@fdncred

fdncred commented Sep 4, 2023

Copy link
Copy Markdown
Contributor

ah, ok. makes sense if #10205 has $env.EDITOR = C:\Program Files\Some\Path\To\Editor.exe

@amtoine amtoine left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is cool, thanks for tackling this issue 🙏

it does not break my $env.EDITOR = "nvim" so i'm happy 😌

however, i only get these errors,

Error: nu::shell::cant_convert

  × Can't convert to string or list<string>.
   ╭─[entry #2:1:1]
 1 │ $env.EDITOR = ""
   ·               ─┬
   ·                ╰── can't convert string to string or list<string>
   ╰────
Error: nu::shell::cant_convert

  × Can't convert to string or list<string>.
   ╭─[entry #8:1:1]
 1 │ $env.EDITOR = [ ]
   ·               ─┬─
   ·                ╰── can't convert list<any> to string or list<string>
   ╰────

and never the first one in the source code, is that normal?
i.e. is there a way to get the $EDITOR or $VISUAL should be an non-empty String or List<String> error? 😋

@horasal

horasal commented Sep 4, 2023 •

Copy link
Copy Markdown
Contributor Author

@amtoine I forgot add error messages for them and now it works :)

error message

Edit: Typo check fails for unknown reason 😢

Error: Can't use 'tar -xzf' extract archive file: /home/runner/work/_actions/_temp_d922c33c-b681-4e6f-844c-563d92470218/5eb8af81-03b9-4285-8551-6eb35bf22509.tar.gz. return code: 2.

@sholderbach

Copy link
Copy Markdown
Member

Thanks for tackling this! Quick question: Do we need to make a similar change to reedline?

@sholderbach sholderbach linked an issue Sep 4, 2023 that may be closed by this pull request
@horasal

horasal commented Sep 4, 2023 •

Copy link
Copy Markdown
Contributor Author

so `nu-cli` can use it
@amtoine

amtoine commented Sep 5, 2023

Copy link
Copy Markdown
Member

this stills works with $env.EDITOR = "nvim" so i'm happy 👍

@Poyo-SSB
can you still reproduce the original issue you are having with these changes? 😇

@horasal

horasal commented Sep 6, 2023 •

Copy link
Copy Markdown
Contributor Author

5bc3863 make the same change to BufferEditor, but it only compiles with nushell/reedline#630

@amtoine

amtoine commented Sep 7, 2023

Copy link
Copy Markdown
Member

5bc3863 make the same change to BufferEditor, but it only compiles with nushell/reedline#630

this makes me think we won't be able to land this PR until nushell/reedline#630 is released 🤔

@horasal

horasal commented Sep 7, 2023

Copy link
Copy Markdown
Contributor Author

Seems reedline side may take some time, so I reverted 5bc3863
and will open another pr when reedline is ready.

Now this pr is safe to be merged :)

sholderbach pushed a commit to sholderbach/nushell that referenced this pull request Sep 29, 2023
move `get_editor` to `cmd-base`
so `nu-cli` can use it
sholderbach pushed a commit to sholderbach/nushell that referenced this pull request Sep 29, 2023
move `get_editor` to `cmd-base`
so `nu-cli` can use it
@sholderbach

Copy link
Copy Markdown
Member

I bundled this up with #10269 in #10535 so I will close this one. Thanks for the work!

sholderbach added a commit that referenced this pull request Sep 29, 2023
# Description
This merges @horasal 's changes from #10246 and #10269

Closes #10205
Closes #8714

Fixes the bug that editor paths with spaces are unusable

Closes #10210 
Closes #10269


# User-Facing Changes
You can now either pass a string with the name of the executable or a
list with the executable and any flags to
`$env.config.buffer_editor`/`$env.EDITOR`/`$env.VISUAL`

Both the external buffer editor of reedline (by default bound to
`Ctrl-o`) and the commands `config nu` and `config env` will respect
those variables in the following order:
1. `$env.config.buffer_editor`
2. `$env.EDITOR`
3. `$env.VISUAL`

Example:
```
$env.EDITOR = "nvim"                      # The system-wide EDITOR is neovim
$env.config.buffer_editor = ["vim" "-p2"] # Force vim to open two tabs (not particularly useful)
$env.config.buffer_editor = null          # Unset `buffer_editor` -> Uses `$env.EDITOR` ergo nvim
```
# Tests + Formatting
None

---------

Co-authored-by: Horasal <[email protected]>
hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
# Description
This merges @horasal 's changes from nushell#10246 and nushell#10269

Closes nushell#10205
Closes nushell#8714

Fixes the bug that editor paths with spaces are unusable

Closes nushell#10210 
Closes nushell#10269


# User-Facing Changes
You can now either pass a string with the name of the executable or a
list with the executable and any flags to
`$env.config.buffer_editor`/`$env.EDITOR`/`$env.VISUAL`

Both the external buffer editor of reedline (by default bound to
`Ctrl-o`) and the commands `config nu` and `config env` will respect
those variables in the following order:
1. `$env.config.buffer_editor`
2. `$env.EDITOR`
3. `$env.VISUAL`

Example:
```
$env.EDITOR = "nvim"                      # The system-wide EDITOR is neovim
$env.config.buffer_editor = ["vim" "-p2"] # Force vim to open two tabs (not particularly useful)
$env.config.buffer_editor = null          # Unset `buffer_editor` -> Uses `$env.EDITOR` ergo nvim
```
# Tests + Formatting
None

---------

Co-authored-by: Horasal <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config nu fails due to mysterious unquoted path config.buffer_editor "The system cannot find the file specified."

4 participants