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

add break action for function list #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 21 additions & 9 deletions src/functions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IList, ListAction, ListContext, ListItem, Neovim } from 'coc.nvim'
import { IList, ListAction, ListContext, ListItem, Neovim, window } from 'coc.nvim'
import colors from 'colors/safe'

export default class Functions implements IList {
Expand All @@ -12,15 +12,27 @@ export default class Functions implements IList {
name: 'open',
execute: async item => {
if (Array.isArray(item)) return
let { funcname } = item.data
let res = await nvim.eval(`split(execute("verbose function ${funcname}"),"\n")[1]`) as string
const { funcname } = item.data
const res = await nvim.eval(`split(execute("verbose function ${funcname}"),"\n")[1]`) as string

let [filepath, _ ,line] = res.replace(/^\s+Last\sset\sfrom\s+/, '').split(/\s+/)
if (line) {
nvim.command(`edit +${line} ${filepath}`, true)
} else {
nvim.command(`edit +/${funcname} ${filepath}`, true)
}
const [filepath, _ ,line] = res.replace(/^\s+Last\sset\sfrom\s+/, '').split(/\s+/)
if (line) {
nvim.command(`edit +${line} ${filepath}`, true)
} else {
nvim.command(`edit +/${funcname} ${filepath}`, true)
}
}
})
this.actions.push({
name: 'break',
execute: async item => {
if (Array.isArray(item)) return
const { funcname } = item.data
const breakcmd = `breakadd func ${funcname}`
nvim.command(breakcmd, true)
// close coc-list after setting breakpoint
nvim.command("CocListCancel", true)
window.showMessage(breakcmd)
}
})
}
Expand Down