davsclaus commented on code in PR #25204:
URL: https://github.com/apache/camel/pull/25204#discussion_r3701425555


##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/SourceViewer.java:
##########
@@ -171,6 +190,40 @@ void reset() {
         quickDocEntries = Collections.emptyMap();
         deprecatedLineScanner = null;
         deprecatedLines = Collections.emptySet();
+        editableFile = null;
+        saveMessage = null;
+        saveError = false;
+    }
+
+    boolean isMarkdownMode() {

Review Comment:
   Minor: `isEditable()` performs two filesystem stat calls 
(`Files.isRegularFile()` + `Files.isWritable()`) on every invocation. Since 
`renderFooter()` calls this on every render frame, that's ~120 stat calls/sec. 
The writable check was already done in `loadFile()` where `editableFile` is set 
to `null` for non-writable paths, so this could be simplified to `return 
editableFile != null`.
   
   ```suggestion
       boolean isEditable() {
           return editableFile != null;
       }
   ```



##########
dsl/camel-jbang/camel-jbang-plugin-tui/src/main/java/org/apache/camel/dsl/jbang/core/commands/tui/FolderBrowser.java:
##########
@@ -184,11 +184,13 @@ boolean handleMouseEvent(MouseEvent me) {
 
     boolean handleKeyEvent(KeyEvent ke) {
         if (sourceViewer.isVisible()) {

Review Comment:
   Nit: with `sourceViewer.handleKeyEvent(ke)` called first, an Esc in non-edit 
mode is now handled by `handleKeyEvent` (which sets `visible=false`, 
`onLineSelected=null`, `editableFile=null`) rather than by 
`sourceViewer.hide()` (which additionally clears `quickDocEnabled`, 
`quickDocEntries`, `deprecatedLines`, `saveMessage`, `saveError`). In 
FolderBrowser's usage this is likely benign since quickDoc isn't used here, but 
could leave stale `deprecatedLines` or `saveMessage` state across viewer 
sessions.



-- 
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]

Reply via email to