fix startScroll == undfined,增加原型链的代码提示
This commit is contained in:
parent
0ad723d2db
commit
97a8442ba4
|
@ -10259,6 +10259,8 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
cm.on("scroll", this.onScroll = function () {
|
cm.on("scroll", this.onScroll = function () {
|
||||||
|
// fix "startScroll == undfined"
|
||||||
|
if (!startScroll) return;
|
||||||
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
|
||||||
var newTop = top + startScroll.top - curScroll.top;
|
var newTop = top + startScroll.top - curScroll.top;
|
||||||
var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop);
|
var point = newTop - (parentWindow.pageYOffset || (ownerDocument.documentElement || ownerDocument.body).scrollTop);
|
||||||
|
|
14
game/game.js
14
game/game.js
|
@ -7506,8 +7506,7 @@
|
||||||
//覆盖原本的javascript提示
|
//覆盖原本的javascript提示
|
||||||
CodeMirror.registerHelper('hint','javascript',(editor,options)=>{
|
CodeMirror.registerHelper('hint','javascript',(editor,options)=>{
|
||||||
//Find the token at the cursor
|
//Find the token at the cursor
|
||||||
let cur=editor.getCursor(),
|
let cur=editor.getCursor(),token=editor.getTokenAt(cur);
|
||||||
token=editor.getTokenAt(cur);
|
|
||||||
if(/\b(?:string|comment)\b/.test(token.type)) return;
|
if(/\b(?:string|comment)\b/.test(token.type)) return;
|
||||||
const innerMode=CodeMirror.innerMode(editor.getMode(),token.state);
|
const innerMode=CodeMirror.innerMode(editor.getMode(),token.state);
|
||||||
if (innerMode.mode.helperType==="json") return;
|
if (innerMode.mode.helperType==="json") return;
|
||||||
|
@ -7523,10 +7522,9 @@
|
||||||
};
|
};
|
||||||
}else if(token.end>cur.ch){
|
}else if(token.end>cur.ch){
|
||||||
token.end=cur.ch;
|
token.end=cur.ch;
|
||||||
token.string=token.string.slice(0,cur.ch- oken.start);
|
token.string=token.string.slice(0,cur.ch-token.start);
|
||||||
}
|
}
|
||||||
let tprop=token;
|
let tprop=token,context;
|
||||||
let context;
|
|
||||||
//If it is a property, find out what it is a property of.
|
//If it is a property, find out what it is a property of.
|
||||||
while (tprop.type=="property"){
|
while (tprop.type=="property"){
|
||||||
tprop=editor.getTokenAt(CodeMirror.Pos(cur.line,tprop.start));
|
tprop=editor.getTokenAt(CodeMirror.Pos(cur.line,tprop.start));
|
||||||
|
@ -7540,8 +7538,10 @@
|
||||||
try {
|
try {
|
||||||
const code=context.length==1?context[0].string:context.reduceRight((pre,cur)=>(pre.string||pre)+'.'+cur.string);
|
const code=context.length==1?context[0].string:context.reduceRight((pre,cur)=>(pre.string||pre)+'.'+cur.string);
|
||||||
const obj=eval(code);
|
const obj=eval(code);
|
||||||
const keys=Object.getOwnPropertyNames(obj).filter(key=>key.startsWith(token.string));
|
if(![null,undefined].includes(obj)){
|
||||||
list.addArray(keys);
|
const keys=Object.getOwnPropertyNames(obj).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(obj))).filter(key=>key.startsWith(token.string));
|
||||||
|
list.addArray(keys);
|
||||||
|
}
|
||||||
}catch(_){ return;}
|
}catch(_){ return;}
|
||||||
}else if(token&&typeof token.string=='string'){
|
}else if(token&&typeof token.string=='string'){
|
||||||
const javascriptKeywords=("break case catch class const continue debugger default delete do else export extends from false finally for function " +
|
const javascriptKeywords=("break case catch class const continue debugger default delete do else export extends from false finally for function " +
|
||||||
|
|
Loading…
Reference in New Issue