Skip to content

Commit 86c8a0b

Browse files
gregoriasmrcjkb
andauthored
fix(mod): handle case where mod decl exists (#19)
* feat(mod): handle case where mod decl exists * Update CHANGELOG.md * Update CHANGELOG.md --------- Co-authored-by: Marc Jakobi <[email protected]>
1 parent db2d7b9 commit 86c8a0b

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ All notable changes to this project will be documented in this file.
66
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
77
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
88

9+
## [1.4.2] - 2023-12-09
10+
11+
### Fixed
12+
13+
- Made the `mod` snippet handle the case where the module declaration already
14+
exists.
15+
Thanks [@gregorias](https://github.com/gregorias)!
16+
917
## [1.4.1] - 2023-12-05
1018

1119
### Fixed

lua/haskell-snippets/util.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,11 @@ local get_clients = vim.lsp.get_clients or vim.lsp.get_active_clients
7373
function util.lsp_get_module_name()
7474
if #get_clients { bufnr = 0 } > 0 then
7575
for _, lens in pairs(vim.lsp.codelens.get(0)) do
76-
local name = lens.command.title:match('module (.*) where')
76+
-- Strings to match taken from the module name plugin:
77+
-- https://github.com/haskell/haskell-language-server/blob/f0c16469046bd554828ea057b5e1f047ad02348e/plugins/hls-module-name-plugin/src/Ide/Plugin/ModuleName.hs#L129-L136
78+
local name_module_decl_absent = lens.command.title:match('module (.*) where')
79+
local name_module_decl_present = lens.command.title:match('Set module name to (.*)')
80+
local name = name_module_decl_absent or name_module_decl_present
7781
if name then
7882
return name
7983
end

0 commit comments

Comments
 (0)