Skip to content

Commit

Permalink
fix(mouse): fix mouse dragging
Browse files Browse the repository at this point in the history
Fixes: #27
  • Loading branch information
lewis6991 committed Jul 5, 2023
1 parent 6591308 commit 9e72344
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 27 deletions.
11 changes: 2 additions & 9 deletions lua/satellite/autocmd/mark.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
--- This module implements a user autocmd for Mark events
---
--- The data fields is populated depending on the specific search event:
--- ...
---

local util = require 'satellite.util'
local config = require 'satellite.config'
Expand All @@ -21,7 +17,6 @@ local group = api.nvim_create_augroup('satellite_autocmd_mark', {})
---@param m string mark name
local function mark_set_keymap(m)
local key = config.user_config.handlers.marks.key .. m
---@diagnostic disable-next-line: missing-parameter
if fn.maparg(key) == '' then
vim.keymap.set({ 'n', 'x' }, key, function()
exec_autocmd { key = key }
Expand All @@ -30,13 +25,11 @@ local function mark_set_keymap(m)
end
end

-- range over A-Z
for code = 65, 90 do
for code = string.byte('A'), string.byte('Z') do
mark_set_keymap(string.char(code))
end

-- -- range over a-z
for code = 97, 122 do
for code = string.byte('a'), string.byte('z') do
mark_set_keymap(string.char(code))
end

Expand Down
8 changes: 1 addition & 7 deletions lua/satellite/autocmd/search.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ end)

-- Refresh when activating search nav mappings
for _, seq in ipairs { 'n', 'N', '&', '*' } do
---@diagnostic disable-next-line: missing-parameter
if fn.maparg(seq) == '' then
vim.keymap.set('n', seq, function()
exec_autocmd { key = seq }
Expand All @@ -45,15 +44,10 @@ for _, seq in ipairs { 'n', 'N', '&', '*' } do
end

local function is_search_mode()
if
vim.o.incsearch
return vim.o.incsearch
and vim.o.hlsearch
and api.nvim_get_mode().mode == 'c'
and vim.tbl_contains({ '/', '?' }, fn.getcmdtype())
then
return true
end
return false
end

local group = api.nvim_create_augroup('satellite_autocmd_search', {})
Expand Down
3 changes: 1 addition & 2 deletions lua/satellite/handlers/diagnostic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ function handler.update(bufnr, winid)
local diags = vim.diagnostic.get(bufnr)
for _, diag in ipairs(diags) do
if diag.severity <= config.min_severity then
local lnum = diag.lnum + 1
local pos = util.row_to_barpos(winid, lnum - 1)
local pos = util.row_to_barpos(winid, diag.lnum)

local count = 1
if marks[pos] and marks[pos].count then
Expand Down
8 changes: 1 addition & 7 deletions lua/satellite/handlers/marks.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local util = require 'satellite.util'
local view = require 'satellite.view'

local highlight = 'MarkSV'

Expand All @@ -26,12 +25,7 @@ local config = {}
---@param m string mark name
---@return boolean
local function mark_is_builtin(m)
for _, mark in pairs(BUILTIN_MARKS) do
if mark == m then
return true
end
end
return false
return vim.list_contains(BUILTIN_MARKS, m)
end

function handler.setup(config0, update)
Expand Down
1 change: 1 addition & 0 deletions lua/satellite/mouse.lua
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ function M.handle_leftmouse()
M.refresh_bars()
end
view.move_scrollbar(winid, row0)
vim.cmd.redraw()
end
end
count = count + 1
Expand Down
4 changes: 2 additions & 2 deletions lua/satellite/view.lua
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ local render = async.void(function(bbufnr, winid, row, height)
end

-- local bwinid = winids[winid]
-- if api.nvim_win_is_valid(winid) and api.nvim_win_is_valid(bwinid) then
-- if bwinid and api.nvim_win_is_valid(winid) and api.nvim_win_is_valid(bwinid) then
-- reposition_bar(winid, bwinid, row)
-- end
end)
Expand Down Expand Up @@ -327,7 +327,7 @@ function M.move_scrollbar(winid, row)
local height = api.nvim_win_get_var(bar_winid, 'height')

local bar_bufnr0 = api.nvim_win_get_buf(bar_winid)
render(bar_bufnr0, bar_winid, winid, row, height)
render(bar_bufnr0, winid, row, height)
end

function M.refresh_bars()
Expand Down

0 comments on commit 9e72344

Please sign in to comment.