Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File name not passed to external editor #432

Open
icyrockcom opened this issue Jun 29, 2020 · 9 comments
Open

File name not passed to external editor #432

icyrockcom opened this issue Jun 29, 2020 · 9 comments
Labels

Comments

@icyrockcom
Copy link

I set this:

Preferences
  View & Edit
    Use external command
      Command line = vim %F
      Execute command in terminal tab = checked

This launches vim, but %F is not passed. Looking at the code:

options.set('shell_command', split_command[0])

shell_command is only the command itself (vim), while arguments is the full command (vim %F with %F replaced). This is then sent to create_terminal_tab which uses only shell_command

terminal_command = shlex.split(terminal_command.format('', shell_command, path))

I assume you'd want something along the lines of ''.join(options.get('arguments', []) there, right?

@MeanEYE
Copy link
Owner

MeanEYE commented Jun 29, 2020

According to command menu formatting, there's no such thing as %F. I understand the expectation for it to behave the same way as "open with" dialog. Try replacing with %S and see if that solves the issue. Eventually I'll have to modify this functionality to behave the same way as other implementations in the system.

@icyrockcom
Copy link
Author

According to command menu formatting, there's no such thing as %F.

Isn't this triggered for %F when replacing editor comand?

exec_string = exec_string.replace('%F', ' '.join(normal_list))

Try replacing with %S and see if that solves the issue.

Using vim %S did not work either with the settings I had. It still passing only vim and not anything after that. Even putting vim hello won't pass hello to vim.

@MeanEYE
Copy link
Owner

MeanEYE commented Jun 30, 2020

What you linked is for general file associations. Executing commands is done from here:

def _handle_command_click(self, widget, data=None):

I'll take a look why it's not working for you.

@MeanEYE MeanEYE added the bug label Jun 30, 2020
@icyrockcom
Copy link
Author

Interesting, I cloned the repo and put a print statement just below

https://github.com/MeanEYE/Sunflower/blob/develop/sunflower/associations.py#L76

i.e. something like:

      # prepare multiple selection
      if '%F' in command:
        exec_string = exec_string.replace('%F', ' '.join(normal_list))
        print('replacing {}'.format(normal_list))

and the print statement was executed when I F4 over a file, so I thought this is where it goes through.

That was on the default develop branch:

* develop c40b0856 Clipboard: Added command line provider.

which doesn't seem to have _handle_command_click anymore, so maybe I should have been using a different branch?

Anyway, let me know if you need anything else to reproduce on your end. It's not a huge deal since it sets the correct cwd, so I can :e the file from vim.

@MeanEYE
Copy link
Owner

MeanEYE commented Jul 6, 2020

This is an issue and bunch of them appeared out of nowhere with migration to Py3 and GTK3. So it needs to be fixed. Thanks I'll let you know when it's time to test.

@ahornero
Copy link

I think is now apparently working, see below :-) BTW, how can we create a custom key binding for a new command? Is there any way available? I couldn't find it.

tilix -e "vi '%S'"

Thanks!

@MeanEYE
Copy link
Owner

MeanEYE commented Sep 28, 2022

Thanks for reporting this @ahornero. There's not direct key -> command mapping. There is a shortcut for dropping down commands menu where you should be able to search and execute commands.

@ahornero
Copy link

Thanks for letting me know @MeanEYE. And congratulations on this awesome piece of software!

@MeanEYE
Copy link
Owner

MeanEYE commented Sep 28, 2022

Thanks. I should probably rework that menu a bit and make it invokeable anywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants