瀏覽代碼

HackStudio: Always use relative paths when opening project files

Itamar 4 年之前
父節點
當前提交
c4139be461
共有 2 個文件被更改,包括 6 次插入2 次删除
  1. 0 1
      Userland/DevTools/HackStudio/Editor.cpp
  2. 6 1
      Userland/DevTools/HackStudio/HackStudioWidget.cpp

+ 0 - 1
Userland/DevTools/HackStudio/Editor.cpp

@@ -431,7 +431,6 @@ void Editor::set_document(GUI::TextDocument& doc)
 
     if (m_language_client) {
         set_autocomplete_provider(make<LanguageServerAidedAutocompleteProvider>(*m_language_client));
-        dbgln("Opening {}", code_document.file_path());
         int fd = open(code_document.file_path().characters(), O_RDONLY | O_NOCTTY);
         if (fd < 0) {
             perror("open");

+ 6 - 1
Userland/DevTools/HackStudio/HackStudioWidget.cpp

@@ -210,8 +210,13 @@ Vector<String> HackStudioWidget::selected_file_names() const
     return files;
 }
 
-void HackStudioWidget::open_file(const String& filename)
+void HackStudioWidget::open_file(const String& full_filename)
 {
+    String filename = full_filename;
+    if (full_filename.starts_with(project().root_path())) {
+        filename = LexicalPath::relative_path(full_filename, project().root_path());
+    }
+    dbgln("HackStudio is opening {}", filename);
     if (Core::File::is_directory(filename))
         return;