Skip to content
Snippets Groups Projects
Commit d328472d authored by Franco Pariani's avatar Franco Pariani
Browse files

Show pop-up hints when is writing and also accept dashs and underscores

parent 6ce61821
No related branches found
No related tags found
No related merge requests found
...@@ -31,13 +31,13 @@ ...@@ -31,13 +31,13 @@
CodeMirror.hint.anyword = function(cm) { CodeMirror.hint.anyword = function(cm) {
var cur = cm.getCursor(), token = cm.getTokenAt(cur) var cur = cm.getCursor(), token = cm.getTokenAt(cur)
var term, from = CodeMirror.Pos(cur.line, token.start), to = cur var term, from = CodeMirror.Pos(cur.line, token.start), to = cur
if (token.start < cur.ch && /\w/.test(token.string.charAt(cur.ch - token.start - 1))) { if (token.start < cur.ch && /[\w\-\_]/.test(token.string.charAt(cur.ch - token.start - 1))) {
term = token.string.substr(0, cur.ch - token.start) term = token.string.substr(0, cur.ch - token.start)
} else { } else {
term = "" term = ""
from = cur from = cur
} }
var inner = anyWord(cm) || {from: from, to: to, list: []}; var inner = anyWord(cm, { word: /[\w$\-\_]+/ }) || {from: from, to: to, list: []};
var filtered_words = defualt_words.filter(w => w.indexOf(term) === 0); var filtered_words = defualt_words.filter(w => w.indexOf(term) === 0);
......
...@@ -68,7 +68,7 @@ ...@@ -68,7 +68,7 @@
</ng-template> </ng-template>
</form> </form>
</div> </div>
<codemirror class="codemirrorPrograma" [(ngModel)]="archivo.contenido" (keyup)="archivoModificado()" [config]="configCodeMirror" [ngStyle]="{'font-size': configCodeMirror.fontSize+'px'}"> <codemirror class="codemirrorPrograma" [(ngModel)]="archivo.contenido" (keyup)="archivoModificado($event)" [config]="configCodeMirror" [ngStyle]="{'font-size': configCodeMirror.fontSize+'px'}">
</codemirror> </codemirror>
</div> </div>
......
...@@ -413,7 +413,9 @@ export class MateFunComponent { ...@@ -413,7 +413,9 @@ export class MateFunComponent {
this.copiaContenidoArchivo = ''; this.copiaContenidoArchivo = '';
} }
archivoModificado(){ archivoModificado(event){
if (/^[a-zA-Z\-\_]$/.test(event.key))
this.codemirror.instance.showHint(event);
if(this.copiaNombreArchivo!=this.archivo.nombre || this.copiaContenidoArchivo != this.archivo.contenido){ if(this.copiaNombreArchivo!=this.archivo.nombre || this.copiaContenidoArchivo != this.archivo.contenido){
this.modificado = true; this.modificado = true;
}else{ }else{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment