Skip to content

Commit

Permalink
Adapt paths and line breaks for Windows (#5471)
Browse files Browse the repository at this point in the history
* Adapt paths and line breaks for Windows
Fix typos

* Only alter strings on Windows.

---------

Co-authored-by: Ahmed Yarub Hani Al Nuaimi <ahmedyarub@yahoo.com>
  • Loading branch information
ahmedyarub and Ahmed Yarub Hani Al Nuaimi authored Oct 18, 2023
1 parent 8532fe6 commit 9aeb741
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
4 changes: 2 additions & 2 deletions DEV_IDE_SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 9aeb741

Please sign in to comment.