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

use the default import of atom-select-list #1727

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
18 changes: 10 additions & 8 deletions lib/toggle-view.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CompositeDisposable, Emitter, Disposable } from 'atom'

// https://github.com/atom/atom-select-list/pull/31
let SelectListView: any
let SelectListViewImport: (typeof import("atom-select-list"))["default"]

type ToggleAction = 'enable' | 'disable'

export default class ToggleView {
Expand Down Expand Up @@ -40,19 +40,21 @@ export default class ToggleView {
}
atom.config.set('linter.disabledProviders', this.disabledProviders)
}
show() {
if (!SelectListView) {
SelectListView = require('atom-select-list')
async show() {
if (SelectListViewImport === undefined) {
SelectListViewImport = (await import('atom-select-list')).default
}
const selectListView = new SelectListView({
const selectListView = new SelectListViewImport({
items: this.getItems(),
emptyMessage: 'No matches found',
elementForItem: (item: any) => {
// @ts-ignore
elementForItem: (item: string) => {
const li = document.createElement('li')
li.textContent = item
return li
},
didConfirmSelection: (item: any) => {
// @ts-ignore
didConfirmSelection: (item: string) => {
try {
this.process(item)
this.dispose()
Expand Down