Skip to content

Commit 65282b0

Browse files
author
sakuraash
committed
fix some lsp error
1 parent 1340308 commit 65282b0

File tree

4 files changed

+62
-66
lines changed

4 files changed

+62
-66
lines changed

app/components/Editor/state.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,6 @@ class Editor {
8080
// }
8181
// })
8282

83-
autorun(() => {
84-
if (this.tab && this.tab.isActive && this.tab.editor && this.tab.editor.cm) {
85-
setTimeout(() => {
86-
this.tab.editor.cm.refresh();
87-
this.tab.editor.cm.focus();
88-
}, 0);
89-
}
90-
})
91-
9283
if (!this.file) {
9384
cm.setCursor(cm.posFromIndex(this.content.length))
9485
}

app/components/MonacoEditor/MonacoReact/BaseEditor.jsx

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -78,60 +78,60 @@ class MonacoEditor extends React.PureComponent {
7878
}
7979
})
8080

81-
autorun(() => {
82-
const languageClient = languageState.clients.get(this.language)
83-
if (languageClient) {
84-
let path, content
85-
if (this.editor.file) {
86-
path = this.editor.file.path
87-
content = this.editor.file.content
88-
} else {
89-
path = this.editor.uri
90-
content = this.editor.content
91-
}
92-
/**
93-
* client 状态
94-
* enum ClientState {
95-
* Initial, // 0
96-
* Starting, // 1
97-
* StartFailed, // 2
98-
* Running, // 3
99-
* Stopping, // 4
100-
* Stopped, // 5
101-
* }
102-
*/
103-
const uri = path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`
104-
let model = monaco.editor.getModel(uri)
105-
if (!model) {
106-
model = monaco.editor.createModel(
107-
content,
108-
this.language.toLowerCase(),
109-
monaco.Uri.parse(path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`)
110-
)
111-
this.uri = path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`
112-
const tmpModel = monaco.editor.getModel(`inmemory://model/${this.editor.id}`)
113-
if (tmpModel) {
114-
tmpModel.dispose()
115-
}
116-
}
117-
this.editor.model = model
118-
monacoEditor.setModel(model)
119-
const { client, openeduri } = languageClient
120-
if (client && client.state === 3 && this.props.active && this.didmount) {
121-
// if (!openeduri.get(path)) {
122-
// languageClient.openTextDocument({
123-
// textDocument: {
124-
// uri: path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`,
125-
// languageId: this.language.toLowerCase(),
126-
// text: content,
127-
// version: 1,
128-
// }
129-
// })
130-
// openeduri.set(path, content)
131-
// }
132-
}
133-
}
134-
})
81+
// autorun(() => {
82+
// const languageClient = languageState.clients.get(this.language)
83+
// if (languageClient) {
84+
// let path, content
85+
// if (this.editor.file) {
86+
// path = this.editor.file.path
87+
// content = this.editor.file.content
88+
// } else {
89+
// path = this.editor.uri
90+
// content = this.editor.content
91+
// }
92+
// /**
93+
// * client 状态
94+
// * enum ClientState {
95+
// * Initial, // 0
96+
// * Starting, // 1
97+
// * StartFailed, // 2
98+
// * Running, // 3
99+
// * Stopping, // 4
100+
// * Stopped, // 5
101+
// * }
102+
// */
103+
// const uri = path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`
104+
// let model = monaco.editor.getModel(uri)
105+
// if (!model) {
106+
// model = monaco.editor.createModel(
107+
// content,
108+
// this.language.toLowerCase(),
109+
// monaco.Uri.parse(path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`)
110+
// )
111+
// this.uri = path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`
112+
// const tmpModel = monaco.editor.getModel(`inmemory://model/${this.editor.id}`)
113+
// if (tmpModel) {
114+
// tmpModel.dispose()
115+
// }
116+
// }
117+
// this.editor.model = model
118+
// monacoEditor.setModel(model)
119+
// const { client, openeduri } = languageClient
120+
// if (client && client.state === 3 && this.props.active && this.didmount) {
121+
// // if (!openeduri.get(path)) {
122+
// // languageClient.openTextDocument({
123+
// // textDocument: {
124+
// // uri: path.startsWith('jdt://') || path.startsWith('omnisharp-metadata') ? path : `file://${languageClient._ROOT_URI_}${path}`,
125+
// // languageId: this.language.toLowerCase(),
126+
// // text: content,
127+
// // version: 1,
128+
// // }
129+
// // })
130+
// // openeduri.set(path, content)
131+
// // }
132+
// }
133+
// }
134+
// })
135135
}
136136

137137
componentWillReceiveProps (nextProps) {

app/components/MonacoEditor/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const toDefinition = registerAction('monaco:goto_definition', (params) =>
4646
selection: params.options.selection,
4747
content: data,
4848
readOnly: true,
49-
filePath: name,
49+
filePath: `${formattedUri.substr(0, formattedUri.length - 5)}java`,
5050
},
5151
})
5252
})

app/components/MonacoEditor/state.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ class EditorInfo {
4545
state.entities.set(this.id, this)
4646
EditorState.entities.set(this.id, this)
4747
this.update(props)
48-
this.uri = this.filePath || `inmemory://model/${this.id}`
48+
this.uri = this.filePath
49+
? (this.filePath.startsWith('jdt://')
50+
|| this.filePath.startsWith('omnisharp-metadata://')
51+
? this.filePath
52+
: `file://${config._ROOT_URI_}${this.filePath}`)
53+
: `inmemory://model/${this.id}`
54+
4955
if (!props.filePath || this.isMonaco) {
5056
this.createMonacoEditorInstance(props)
5157
}
@@ -60,7 +66,6 @@ class EditorInfo {
6066
if (this.filePath) {
6167
this.languageMode = findLanguageByextensions(this.filePath.split('.').pop()).id
6268
}
63-
6469
const model =
6570
monaco.editor.getModel(monaco.Uri.parse(this.uri).toString()) ||
6671
monaco.editor.createModel(this.content || '', this.languageMode, monaco.Uri.parse(this.uri))

0 commit comments

Comments
 (0)