michael-hoke commented on PR #1384:
URL: https://github.com/apache/daffodil-vscode/pull/1384#issuecomment-3285779834

   Yeah, this is unfortunately going to be implementation-specific on the part 
of the file dialog. I think Windows should be expected to append the extension, 
and most Linux/Mac platforms will as well, but it's not guaranteed.
   
   I'd probably use a couple of regexes to solve this - something like this 
(I'm also dropping the global flag - I don't think we want it here):
   ``` 
   // Create capture groups for the path
   // Capture Group 2 will be all valid extensions potentially chained at the 
end of the path
   // Capture Group 1 will be the rest of the filename (before the valid 
extensions)
   matches = pathStr.match(/(^.*)((\.tdml|\.tdml\.xml)*)$/i)
   if (matches) {
     // We want to grab the first valid extension found from the previous 
regex's Capture Group 2
     //    and append that to the filename with TDML extensions stripped 
(previous regex's Capture Group 1)
     extMatches = matches[2].match(/^\.tdml.xml|^\.tdml/i)
     return matches[1] + extMatches
   }
   
   // If our regex didn't match, we don't have a valid extension and it's safe 
to add one
   return pathStr + '.tdml'
   ```
   
   Also, if you add 'tdml.xml' to the filters argument of `showSaveDialog`, 
will that work like I think it will and show files with both extensions? Will 
it also default to still appending `.tdml` if it's first in the list? I don't 
know if I think we should make this change or not. I'd be slightly inclined to 
make it just so that `.tdml.xml` on the user's system show up in the dialog 
window


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