davsclaus commented on code in PR #24545:
URL: https://github.com/apache/camel/pull/24545#discussion_r3548720782
##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/FolderInputPopup.java:
##########
@@ -110,11 +108,15 @@ void showInput() {
void open() {
showInput = true;
- String lastFolder = loadLastFolder();
- if (lastFolder == null) {
- lastFolder = System.getProperty("user.dir");
+ String defaultFolder = TuiSettings.load().getDefaultFolder();
+ String initialFolder;
+ if (defaultFolder != null) {
+ initialFolder = defaultFolder;
+ } else {
+ String lastFolder = loadLastFolder();
+ initialFolder = lastFolder != null ? lastFolder :
System.getProperty("user.dir");
}
- inputState = new TextInputState(lastFolder != null ? lastFolder : "");
+ inputState = new TextInputState(initialFolder);
Review Comment:
The documentation in `camel-jbang-tui.adoc` states:
> *Default Folder* — the folder pre-filled in *Run from Folder*. The most
recently used folder **still takes precedence**; this default is used **only
when there is no remembered folder**.
But the code implements the opposite precedence: `defaultFolder` wins when
set, and `lastFolder` is only checked as a fallback. Per the docs, the intended
order should be `lastFolder` > `defaultFolder` > `user.dir`.
Either the code or the docs need to be corrected. If the intended behavior
is `lastFolder` first:
```suggestion
String lastFolder = loadLastFolder();
String initialFolder;
if (lastFolder != null) {
initialFolder = lastFolder;
} else {
String defaultFolder = TuiSettings.load().getDefaultFolder();
initialFolder = defaultFolder != null ? defaultFolder :
System.getProperty("user.dir");
}
inputState = new TextInputState(initialFolder);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]