Search code examples
pythonsublimetextsublime-text-plugin

use sublime text api open_file(), but path is not correct


I want to write a Sublime Text plugin like ctags for JavaScript, and I need to to use the sublime.Window.open_file() function.

But it is not working, I have printed path, but it seem different with the path I have transmit to api.

print("needOpen  "+needOpen)
root.view.window().open_file(needOpen)

console

needOpen  C:/Users/lujunhao/AppData/Roaming/npm/node_modules/fis/node_modules/fis-kernel/fis-kernel.js

Unable to open /C/Users/lujunhao/AppData/Roaming/npm/node_modules/fis/node_modules/fis-kernel/fis-kernel.js

Solution

  • I have resolved my problem. I make a mistake with ignore to remove "\n". The path which pass to open_file is "c:\abc.txt <\n>".It has newline character. when i print the path , I can't see the newline character. So ............

    Thanks to you all