Skip to content

Commit

Permalink
fix(repl): do not quote file path in builtin repl
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Apr 9, 2023
1 parent fd369e6 commit 2759c2a
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [1.9.6] - 2023-04-09
### Fixed
- Loading files with `'builtin'` repl handler.

## [1.9.5] - 2023-04-06
### Fixed
Expand Down
7 changes: 3 additions & 4 deletions lua/haskell-tools/repl.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

local ht = require('haskell-tools')
local project = require('haskell-tools.project-util')
local ht_util = require('haskell-tools.util')

local repl = {}

Expand Down Expand Up @@ -38,7 +37,7 @@ local function extend_repl_cmd(cmd, file)
return cmd
end
if vim.endswith(file, '.hs') then
table.insert(cmd, ht_util.quote(file))
table.insert(cmd, file)
else
ht.log.debug('extend_repl_cmd: Not a Haskell file.')
table.insert(cmd, subpackage)
Expand All @@ -60,7 +59,7 @@ end
---@param file string|nil
---@return string[]|nil command
local function mk_stack_repl_cmd(file)
return extend_repl_cmd({ 'stack', 'ghci' }, ht_util.quote(file))
return extend_repl_cmd({ 'stack', 'ghci' }, file)
end

---Create the command to create a repl for a file.
Expand All @@ -85,7 +84,7 @@ function repl.mk_repl_cmd(file)
return mk_stack_repl_cmd(file)
end
if vim.fn.executable('ghci') == 1 then
local cmd = vim.tbl_flatten { 'ghci', file and { ht_util.quote(file) } or {} }
local cmd = vim.tbl_flatten { 'ghci', file and { file } or {} }
ht.log.debug { 'mk_repl_cmd', cmd }
return cmd
end
Expand Down
4 changes: 2 additions & 2 deletions lua/haskell-tools/repl/builtin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ local function create_tab(_)
end

---Create a new repl (or toggle its visibility)
---@param create_win function|number Function for creating the window
---@param mk_cmd function Function for creating the repl command
---@param create_win function|number Function for creating the window or an existing window number
---@param mk_cmd fun():string[] Function for creating the repl command
---@param opts ReplViewOpts?
---@return nil
local function create_or_toggle(create_win, mk_cmd, opts)
Expand Down
3 changes: 2 additions & 1 deletion lua/haskell-tools/repl/toggleterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

local ht = require('haskell-tools')
local deps = require('haskell-tools.deps')
local ht_util = require('haskell-tools.util')

local toggleterm = {
terminal = nil,
Expand Down Expand Up @@ -66,7 +67,7 @@ function toggleterm.setup(mk_repl_cmd, opts)
vim.notify(err_msg, vim.log.levels.ERROR)
return
end
local cmd = table.concat(mk_repl_cmd(filepath) or {}, ' ')
local cmd = table.concat(mk_repl_cmd(filepath and ht_util.quote(filepath)) or {}, ' ')
if cmd == '' then
local err_msg = 'haskell-tools.repl.toggleterm: Could not create a repl command.'
ht.log.error(err_msg)
Expand Down

0 comments on commit 2759c2a

Please sign in to comment.