Fixed a bug where documents that were not initialized with a supported language wouldn't recieve language reconfiguration events
This commit is contained in:
parent
4648240842
commit
5d6bdecdfc
@ -16,7 +16,7 @@
|
|||||||
"dev": "neu run",
|
"dev": "neu run",
|
||||||
"build": "neu build",
|
"build": "neu build",
|
||||||
"update": "neu update",
|
"update": "neu update",
|
||||||
"install:neu": "rm src/lib/platform.js && ln lib/platforms/neutralino.js src/lib/platforms.js && ln build/neutralino.js src/lib/neutralino.js"
|
"install:neu": "rm src/lib/platform.js && ln lib/platforms/neutralino.js src/lib/platform.js && ln build/neutralino.js src/lib/neutralino.js"
|
||||||
},
|
},
|
||||||
"type": "module"
|
"type": "module"
|
||||||
}
|
}
|
||||||
|
21
src/qwe.js
21
src/qwe.js
@ -48,18 +48,19 @@ function Editor() {
|
|||||||
this.setDoc = async (doc, bind) => {
|
this.setDoc = async (doc, bind) => {
|
||||||
this.doc = doc
|
this.doc = doc
|
||||||
statusbar.updateFilename()
|
statusbar.updateFilename()
|
||||||
this.view.setState(await this.doc.createState())
|
|
||||||
this.doc.setView(this.view)
|
this.doc.setView(this.view)
|
||||||
|
this.view.setState(await this.doc.createState())
|
||||||
}
|
}
|
||||||
|
|
||||||
this.openDirectory = async (path) => {
|
this.openDirectory = async (path) => {
|
||||||
let fileList = (await Platform.readdir(path))
|
let fileList = (await Platform.readdir(path))
|
||||||
.filter(dirent => dirent.name != '.')
|
.filter(dirent => dirent.name != '.')
|
||||||
.map(dirent => dirent.type == 'FILE' ? dirent.name : dirent.name + '/')
|
.map(dirent => dirent.type == 'FILE' ? dirent.name : dirent.name + '/')
|
||||||
|
.sort()
|
||||||
.join('\n')
|
.join('\n')
|
||||||
|
|
||||||
let doc = new Doc(fileList, Platform.join(path, '~' + Platform.filename(path)))
|
let doc = new Doc(fileList, Platform.join(path, '~' + Platform.filename(path)))
|
||||||
editor.setDoc(doc)
|
this.setDoc(doc)
|
||||||
}
|
}
|
||||||
|
|
||||||
// this.updateFilename = () => {
|
// this.updateFilename = () => {
|
||||||
@ -172,15 +173,10 @@ function Doc(content, initialPath) {
|
|||||||
cm.crosshairCursor(),
|
cm.crosshairCursor(),
|
||||||
cm.highlightSelectionMatches(),
|
cm.highlightSelectionMatches(),
|
||||||
cm.history(),
|
cm.history(),
|
||||||
|
Doc.language.of(this.language ? await langManager.resolveExtension(this.language) : []),
|
||||||
Keymaps.default
|
Keymaps.default
|
||||||
]
|
]
|
||||||
|
|
||||||
if(this.language)
|
|
||||||
extensions.push(
|
|
||||||
await langManager.resolveExtension(this.language)
|
|
||||||
.then(extension => Doc.language.of(extension))
|
|
||||||
)
|
|
||||||
|
|
||||||
return cm.EditorState.create({
|
return cm.EditorState.create({
|
||||||
extensions,
|
extensions,
|
||||||
doc: content
|
doc: content
|
||||||
@ -200,6 +196,9 @@ function Doc(content, initialPath) {
|
|||||||
this.setLanguage()
|
this.setLanguage()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.getView = () =>
|
||||||
|
view
|
||||||
|
|
||||||
this.setLanguage = (newLanguage = getLanguage()) => {
|
this.setLanguage = (newLanguage = getLanguage()) => {
|
||||||
let oldLanguage = this.language
|
let oldLanguage = this.language
|
||||||
this.language = newLanguage
|
this.language = newLanguage
|
||||||
@ -208,7 +207,7 @@ function Doc(content, initialPath) {
|
|||||||
return
|
return
|
||||||
|
|
||||||
if(this.language == null) {
|
if(this.language == null) {
|
||||||
setViewLanguageExtension([])
|
setViewLanguageExtension()
|
||||||
} else if(oldLanguage == null || oldLanguage.name !== this.language.name) {
|
} else if(oldLanguage == null || oldLanguage.name !== this.language.name) {
|
||||||
langManager.resolveExtension(this.language)
|
langManager.resolveExtension(this.language)
|
||||||
.then(setViewLanguageExtension)
|
.then(setViewLanguageExtension)
|
||||||
@ -224,7 +223,9 @@ function Doc(content, initialPath) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const setViewLanguageExtension = (extension) => {
|
const setViewLanguageExtension = (extension = []) => {
|
||||||
|
console.log('lang!', extension)
|
||||||
|
|
||||||
view.dispatch({
|
view.dispatch({
|
||||||
effects: Doc.language.reconfigure(extension)
|
effects: Doc.language.reconfigure(extension)
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user