Skip to content

Commit

Permalink
Merge branch 'release/0.5.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeboster committed Jan 6, 2021
2 parents a45cfa2 + 2f231ab commit a3ec533
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 22 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.5.6
- Properly unhook clickListener
- Minor refactoring

# 0.5.5
- Check current editor also on keyup event
- Github workflow: Properly fix bash if else statement
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ This plugin provides a text autocomplete feature to enhance typing speed.
## Features
There are the current and planned features:
- [x] Triggers with `ctrl+space` or `Toggle Autocomplete` command
- [x] Change suggestion with `Ctrl-n/p` and select with `enter`
- [x] Trigger autocomplete with `ctrl+space` or `Toggle Autocomplete` command
- [x] Change suggestion with `Ctrl-n/p` or `up/down arrows` and select with `enter`
- [x] Autocomplete view style as Obsidian
- [x] Supports multiple autocomplete providers (for now Latex)
- [x] Seamless integration with vim mode
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "obsidian-autocomplete-plugin",
"name": "Autocomplete",
"version": "0.5.5",
"version": "0.5.6",
"minAppVersion": "0.10.0",
"description": "This plugin provides a text autocomplete feature to enhance typing speed.",
"author": "Yeboster",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "autocomplete-obsidian",
"version": "0.5.5",
"version": "0.5.6",
"description": "An Obsidian plugin to provide text autocomplete.",
"main": "index.js",
"author": "Yeboster <yeboster@gmail.com>",
Expand Down
15 changes: 4 additions & 11 deletions src/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,23 +62,16 @@ export default class AutocompleteView {
this.addClickListener(view, editor)

this.view = view
} else if (this.view.children &&
this.view.children[0] &&
this.view.children[0].children) {
} else if (this.view.firstChild && this.view.firstChild.nextSibling) { // Somehow first child is in nextSibling
cachedView = true
const children = this.view.children[0].children
const children = (this.view.firstChild.nextSibling as HTMLElement).children
const selectedIndex = this.selected.index
const selectedClass = 'is-selected'


for (let index = 0; index < children.length; index++) {
const child = children[index]
const classes = child.classList

if (index === selectedIndex) {
if (!classes.contains(selectedClass))
classes.add(selectedClass)
} else if (classes.contains(selectedClass))
classes.remove(selectedClass)
child.toggleClass('is-selected', index === selectedIndex)
}
}

Expand Down
8 changes: 2 additions & 6 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class AutocompletePlugin extends Plugin {
async onunload() {
const workspace = this.app.workspace
workspace.iterateCodeMirrors(cm => {
cm.off('keyup', this.keyupListener.bind(this))
cm.off('keyup', this.keyupListener)
this.autocompleteView.removeView(cm)
})
console.log('Unloaded Obsidian Autocomplete')
Expand All @@ -106,10 +106,6 @@ export default class AutocompletePlugin extends Plugin {
private getCurrentEditor(): CodeMirror.Editor | null {
const view = this.app.workspace.getActiveViewOfType(MarkdownView)

let editor = undefined
if (view)
editor = view.sourceMode.cmEditor

return editor
return view ? view.sourceMode.cmEditor : null
}
}
3 changes: 2 additions & 1 deletion versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"0.5.2": "0.10.1",
"0.5.3": "0.10.0",
"0.5.4": "0.10.0",
"0.5.5": "0.10.0"
"0.5.5": "0.10.0",
"0.5.6": "0.10.0"
}

0 comments on commit a3ec533

Please sign in to comment.