fman-users / fman

Issue tracker for fman, a cross-platform file manager
https://fman.io
240 stars 3 forks source link

open with editor (F4) does not work #windows #638

Closed ghost closed 5 years ago

ghost commented 5 years ago

reproduce

GIVEN: on windows 10 AND: latest fman version AND a file is selected WHEN: F4 is pressed THEN: an error occurs (could not open .myeditorchoice

(docs do not tell about this file, fman is not creating it like F3)

ANALYSIS:

Plugin code from ...\fman\Plugins\Third-party\OpenWithEditor\openwitheditor__init__.py will try to open a .myeditorchoice file

I tracked the code in the plugin and found the line

os.system("/usr/bin/open -a '" + editor + "' '" + as_human_readable(file) + "' &")

that will definitively not work on windows!

I would do the following implmentation


def editFile(editor, file):
    if sys.platform == "win32":                                 #+ 2019-03-16 open editor
        Popen([editor, as_human_readable(file)])                #+ 2019-03-16
    else:                                                       #+ 2019-03-16
        os.system("/usr/bin/open -a '" + editor + "' '" + as_human_readable(file) + "' &")
ghost commented 5 years ago

note that you also have to

import sys                   #+ 2019-03-16
from subprocess import Popen #+ 2019-03-16

really like it if i can fix my app (fman) errors in python 👍

raguay commented 5 years ago

That error comes from my Plugin OpenWithEditor. It assumes you have the TextBar/BitBar plugin that allows you to pick an editor from a list in the menu bar. Please read the instructions for the plugin: https://github.com/raguay/OpenWithEditor

ghost commented 5 years ago

@raguay thanks for the input. I think the issue then mutates to: plugins need to have a platform specification. hence your plugin is not able to be used under windows but was installed there without any note. Would you be willing to integrate some code? even as simple as: if sys.platform != "macos": allert("not supported...")

ghost commented 5 years ago

I added a link to the plugin issues https://github.com/raguay/OpenWithEditor/issues/1 to help other windows-fman users to solve the problem quickly