Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CompatHighlighter.sysFishVer auto modal dialog with Fish 4.0b1 #29

Open
melomac opened this issue Dec 23, 2024 · 0 comments
Open

CompatHighlighter.sysFishVer auto modal dialog with Fish 4.0b1 #29

melomac opened this issue Dec 23, 2024 · 0 comments

Comments

@melomac
Copy link

melomac commented Dec 23, 2024

match = re.search(r'[0-9]+\.[0-9]+\.[0-9]+', out.strip())

Hi

Many thanks for sublime-fish module! It has been (and still is) the companion one can hope for since I am using Sublime Text and fish-shell, for more than a decade.

I'd like to inform you the code to parse the version wouldn't expect the recently introduced 4.0b1 version number:

Error in fish.sublime-settings: The 'auto' setting was unable to determine your fish version. Please report a bug using Preferences > Package Settings > Fish > Report a bug. Include your system information, and the output of 'fish --version' in your terminal. To work around this error, set 'compat_highlighter_fish_version' in the settings file.

Fish version: fish, version 4.0b1-13-g541f8b47b (built with brew install fish --HEAD)

# Currently, I can't imagine this happening. Prove me wrong!

Ahahah

Considering 4.0b1 means 4.0 in term of compatibility, it is probably safe to consider an alternative regular expression to match numbers and dots up to the eventual - separator, as I proposed in virtualfish project here, ex:

diff --git a/highlighter_compat.py b/highlighter_compat.py
index af2804f..c08cb1d 100644
--- a/highlighter_compat.py
+++ b/highlighter_compat.py
@@ -78,7 +78,7 @@ class CompatHighlighter(sublime_plugin.ViewEventListener, BaseHighlighter):
       if out:
         # For builds from source, version string may be e.g. "fish, version 3.0.2-1588-g70fc2611"
         # Hence, we just search() for the match anywhere in the string
-        match = re.search(r'[0-9]+\.[0-9]+\.[0-9]+', out.strip())
+        match = re.search(r'.*version ([\d\.]+)', out.strip())
       else:
         CompatHighlighter.sysFishVer = 'not found' # Couldn't find executable
 
@@ -86,7 +86,7 @@ class CompatHighlighter(sublime_plugin.ViewEventListener, BaseHighlighter):
         sublime.error_message(err)
 
       if match:
-        CompatHighlighter.sysFishVer = match.group(0)
+        CompatHighlighter.sysFishVer = match.group(1)
       elif out:
         CompatHighlighter.sysFishVer = 'error' # This shouldn't happen!
 

But you might prefer something closer to this:

r'fish([0-9]+(?:\.[0-9]+(?:\.[0-9]+)?)?)',

I am going to give it a try and I'll be honored to humbly contribute to your project with such a simple PR.

Many thanks again for maintaining this project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant