From 9aeb741bdc4cf28231eaf3fc548450ef241cbbcd Mon Sep 17 00:00:00 2001 From: Ahmed Yarub Hani Al Nuaimi Date: Wed, 18 Oct 2023 07:10:09 -0300 Subject: [PATCH] Adapt paths and line breaks for Windows (#5471) * Adapt paths and line breaks for Windows Fix typos * Only alter strings on Windows. --------- Co-authored-by: Ahmed Yarub Hani Al Nuaimi --- DEV_IDE_SETUP.md | 4 ++-- .../idea/blaze/base/settings/ui/ProjectViewUi.java | 7 ++++++- .../wizard2/ImportFromWorkspaceProjectViewOption.java | 11 +++++++++-- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/DEV_IDE_SETUP.md b/DEV_IDE_SETUP.md index dce5e4fe952..ce0fc245404 100644 --- a/DEV_IDE_SETUP.md +++ b/DEV_IDE_SETUP.md @@ -8,11 +8,11 @@ When asked, use the bundled project view file (`ijwb/ijwb.bazelproject`). This w - Set the plugin to build with the latest development version by default. - Automatically import the relevant target, and exclude the irrelevant ones. -Depending on which JetBrains product you're targetting, you may want to adjust the `--define` flag in the `build_flags` section. For more information on which values you can pass, please refer to [Building the Plugin](README.md#building-the-plugin) +Depending on which JetBrains product you're targeting, you may want to adjust the `--define` flag in the `build_flags` section. For more information on which values you can pass, please refer to [Building the Plugin](README.md#building-the-plugin) ## Download and Install the JetBrains Runtime SDK -Most of the time, the IntelliJ Platform Plugin SDK bundled with your IntelliJ installation shuould be enuogh to compile and run the plugin. +Most of the time, the IntelliJ Platform Plugin SDK bundled with your IntelliJ installation should be enough to compile and run the plugin. To install it, please head to the SDK menu (`Cmd+;` or `Ctrl+;`), and then to `Platform Settings -> SDKs`. diff --git a/base/src/com/google/idea/blaze/base/settings/ui/ProjectViewUi.java b/base/src/com/google/idea/blaze/base/settings/ui/ProjectViewUi.java index e005290e9e3..7e82935133a 100644 --- a/base/src/com/google/idea/blaze/base/settings/ui/ProjectViewUi.java +++ b/base/src/com/google/idea/blaze/base/settings/ui/ProjectViewUi.java @@ -40,6 +40,7 @@ import com.intellij.openapi.project.ProjectManager; import com.intellij.openapi.project.impl.ProjectImpl; import com.intellij.openapi.util.Disposer; +import com.intellij.openapi.util.SystemInfo; import com.intellij.ui.LanguageTextField; import com.intellij.ui.LanguageTextField.SimpleDocumentCreator; import com.intellij.ui.components.JBLabel; @@ -184,7 +185,11 @@ private void setProjectViewText(String projectViewText) { .runWriteAction( () -> { projectViewEditor.getDocument().setReadOnly(false); - projectViewEditor.getDocument().setText(projectViewText); + if (SystemInfo.isWindows) { + projectViewEditor.getDocument().setText(projectViewText.replace("\r", "")); + } else { + projectViewEditor.getDocument().setText(projectViewText); + } }); updateTextAreasEnabled(); } diff --git a/base/src/com/google/idea/blaze/base/wizard2/ImportFromWorkspaceProjectViewOption.java b/base/src/com/google/idea/blaze/base/wizard2/ImportFromWorkspaceProjectViewOption.java index 3b9fd193779..e43121e616a 100644 --- a/base/src/com/google/idea/blaze/base/wizard2/ImportFromWorkspaceProjectViewOption.java +++ b/base/src/com/google/idea/blaze/base/wizard2/ImportFromWorkspaceProjectViewOption.java @@ -24,6 +24,7 @@ import com.intellij.openapi.fileChooser.FileChooserFactory; import com.intellij.openapi.options.ConfigurationException; import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.LocalFileSystem; @@ -168,13 +169,19 @@ private void chooseWorkspacePath() { } VirtualFile file = files[0]; - if (!FileUtil.startsWith(file.getPath(), fileBrowserRoot.getPath())) { + boolean startsWithPath; + if (SystemInfo.isWindows) { + startsWithPath = FileUtil.startsWith(file.getPath(), fileBrowserRoot.getPath().replace('\\', '/')); + } else { + startsWithPath = FileUtil.startsWith(file.getPath(), fileBrowserRoot.getPath()); + } + if (!startsWithPath) { Messages.showErrorDialog( String.format( "You must choose a project view file under %s. " + "To use an external project view, please use the 'Copy external' option.", fileBrowserRoot.getPath()), - "Cannot Use Project View File"); + String.format("Cannot Use Project View File %s", file.getPath())); return; }