Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
erp5
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Jobs
Commits
Open sidebar
Jérome Perrin
erp5
Commits
6e9c1e23
Commit
6e9c1e23
authored
Nov 08, 2019
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
monaco_editor: enable completion provider for python
this makes completions works when using Ctrl+space
parent
6a0edbf2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
bt5/erp5_monaco_editor/SkinTemplateItem/portal_skins/erp5_monaco_editor/monaco-editor.gadget.js.js
...ortal_skins/erp5_monaco_editor/monaco-editor.gadget.js.js
+49
-0
No files found.
bt5/erp5_monaco_editor/SkinTemplateItem/portal_skins/erp5_monaco_editor/monaco-editor.gadget.js.js
View file @
6e9c1e23
...
...
@@ -334,6 +334,55 @@
yapfDocumentFormattingProvider
);
monaco
.
languages
.
registerCompletionItemProvider
(
'
python
'
,
{
provideCompletionItems
:
async
function
(
model
,
position
,
context
,
token
)
{
const
controller
=
new
AbortController
();
token
.
onCancellationRequested
(()
=>
{
controller
.
abort
();
});
const
data
=
new
FormData
();
const
complete_parameters
=
{
code
:
model
.
getValue
(),
position
:
{
line
:
position
.
lineNumber
,
column
:
position
.
column
}
};
data
.
append
(
'
data
'
,
JSON
.
stringify
(
complete_parameters
));
return
fetch
(
gadget
.
state
.
language_support_url
+
'
/ERP5Site_getPythonSourceCodeCompletionList
'
,
{
method
:
'
POST
'
,
body
:
data
,
signal
:
controller
.
signal
}
)
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
return
{
suggestions
:
data
.
map
(
c
=>
{
c
.
kind
=
monaco
.
languages
.
CompletionItemKind
[
c
.
_kind
];
// this makes monaco render documentation as markdown.
c
.
documentation
=
{
value
:
c
.
documentation
};
return
c
;
})
};
},
e
=>
{
if
(
!
(
e
instanceof
DOMException
)
/* AbortError */
)
{
throw
e
;
}
/* ignore aborted requests */
}
);
}
});
this
.
runPyLint
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment