Skip to content

Commit

Permalink
fix: os_uname check for wsl (#543)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaerald committed Apr 18, 2024
1 parent 1265a1f commit 6ffd196
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Fixed an issue where template insertion occurred below the intended line, it now correctly inserts at the current line.
- Fixed `:ObsidianOpen` issue on WSL OS name identifier check with different release name case.

## [v3.7.8](https://github.com/epwalsh/obsidian.nvim/releases/tag/v3.7.8) - 2024-04-09

Expand Down
6 changes: 3 additions & 3 deletions lua/obsidian/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -437,9 +437,9 @@ util.get_os = function()
if vim.fn.has "win32" == 1 then
this_os = util.OSType.Windows
else
local sysname = vim.loop.os_uname().sysname
local release = vim.loop.os_uname().release
if sysname == "Linux" and string.find(release, "microsoft") then
local sysname = vim.loop.os_uname().sysname:lower()
local release = vim.loop.os_uname().release:lower()
if sysname == "linux" and string.find(release, "microsoft") then
this_os = util.OSType.Wsl
else
this_os = sysname
Expand Down

3 comments on commit 6ffd196

@IvanovSvyatoslav
Copy link

@IvanovSvyatoslav IvanovSvyatoslav commented on 6ffd196 Apr 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, you introduced a bug on MacOS
open command does not support OS type 'darwin'

@IvanovSvyatoslav
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

---@enum OSType
util.OSType = {
  Linux = "Linux",
  Wsl = "Wsl",
  Windows = "Windows",
  Darwin = "Darwin",
  FreeBSD = "FreeBSD",
}

Your function returns sysname in lowercase, but then it compares to uppercase value from Enum

@epwalsh
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, good catch. Fixed.

Please sign in to comment.