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

Confusion over relative paths #11

Closed
breck7 opened this issue May 13, 2015 · 8 comments
Closed

Confusion over relative paths #11

breck7 opened this issue May 13, 2015 · 8 comments
Labels

Comments

@breck7
Copy link

breck7 commented May 13, 2015

Really like this plugin. One thing I'm struggling to grasp is the relative paths.

Let's say my directory structure looks like this:

/fruits/apple.js
/veggies/corn.js

Now let's say I'm editing corn.js. If I type "app" then hit the relative auto completion shortcut I'd expect the inserted text to be relative to the current file. So I expect "../fruits/apple.js". Instead I get "/fruits/apple.js".

Is this as designed?

@sagold
Copy link
Owner

sagold commented May 14, 2015

Thanks for your Feedback.

Hitting relative auto completion should always insert paths relative from your current file. I probably did not mention explicitly that it has to be called before the suggestions are displayed (the shortcut opens the suggestions window). In your case the suggestions window is already opened. Meaning, the selected rule will determine the path type.

Either adjust the ruleset to your specific needs or start the query by hitting the shortcut for relative auto completion.

I hope this helps.
Just let me know if something is missing.

@breck7
Copy link
Author

breck7 commented May 14, 2015

Hey @sagold, thanks for the quick reply.

I'm still seeing the path relative to the project root. I've tried many combinations. I'm hitting the default "ctrl+alt+space" shortcut before the suggestions are displayed. I haven't overridden any of the default package or keyboard settings. Is there a different way to trigger relative auto completion without the keyboard shortcut?

Here's a gif of what I'm trying: http://i.imgur.com/3x7lfCo.gif

The first time I try auto autocomplte, the second time I specifically use the relative auto complete shortcut.

Default Keybindings:

[
    {
        "keys": ["ctrl+alt+space"],
        "command": "insert_path",
        "args": {
            "type": "relative"
        }
    },

    {
        "keys": ["ctrl+shift+space"],
        "command": "insert_path",
        "args": {
            "type": "absolute"
        }
    },

    {
        "keys": ["alt+enter"],
        "command": "ffp_goto_file"
    }
]

@sagold
Copy link
Owner

sagold commented May 19, 2015

Hi Breck.

Would you mind to post some more information so that i may reproduce or solve the problem?

  • Which Sublime Text Version are you using
  • Which OS
  • What is the current scope on the given path (alt+super+p)
  • What is the content of the following tool, if executed on your path: { "keys": ["alt+y"], "command": "ffp_show_context" }

Thank you for your efforts. The animated gif is very helpful.

@breck7
Copy link
Author

breck7 commented May 22, 2015

  • Sublime 3083
  • Windows 10 (hope this isn't the problem as I'm on a daily build)
  • I don't see the ffp_show_context command. And alt+super+p doesn't seem to do anything.

I'll give it a shot on my mac at home and see if it works on there.

Thanks @sagold!

@fetis
Copy link

fetis commented May 23, 2015

It looks like I'm having the same issue. I'm on Windows 7 and Subliime 3083.

When I'm trying to autocomplete filename for require() it's always insterted as absolute. Neither ./ nor ../ prefixes don't work.

Here's my config (pretty copied from standard one)

      {
          // js - require("") and define([""])
          "scope": "source\\.js.*string",   // 1. ignore if scope at cursor does not match expression (super+alt+p)
          "prefix": ["require", "define"],  // 2. trigger only if: require(<cursor>, define([<cursor>
          // if 1 & 2 are true:
          "auto": true,           // auto suggest filepaths, else only by shorctut
          "extensions": ["js"],       // show only .js files
          "relative": true,
          "base_directory": false,       // insert absolute from the set base directory (above)
          "replace_on_insert": [
            ["\\.js$", ""],         // after insertion, remove .js from path
            ["([^.])\\/index$", "\\1"]    // nodejs will load index.js by default => also remove index
          ]
      },

@sagold
Copy link
Owner

sagold commented May 25, 2015

Hi breck, hi fetis.

Thank you both for helping me find the problem. Obviously i am neglecting tests on windows. The problem was twofold:

  • missing treatment of windows paths
  • strange default settings for the require-trigger

Both problems have been fixed, tested and released 3e0e063.

I hope you can confirm that this issue is solved.

@sagold sagold added bug and removed question labels May 25, 2015
@fetis
Copy link

fetis commented May 25, 2015

It looks like problem was fixed. But I had to completely remove the plugin and made fresh installation.
Thanks for your work!

@breck7
Copy link
Author

breck7 commented May 26, 2015

It works! Thanks @sagold !

@breck7 breck7 closed this as completed May 26, 2015
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