From ef5af704cdb11f22e7bef9804fe8090059a16b32 Mon Sep 17 00:00:00 2001 From: Matthijs van Henten Date: Tue, 27 Oct 2015 15:02:46 +0100 Subject: [PATCH] Revert "Fix issues with rename" --- node_modules/ace/lib/ace/edit_session.js | 4 +- .../ace/lib/ace/layer/font_metrics.js | 2 +- node_modules/ace/lib/ace/placeholder.js | 127 ++++++++++-------- node_modules/architect-build/module-deps.js | 7 +- package.json | 4 +- plugins/c9.ide.tree/style.css | 2 +- plugins/c9.ide.tree/tree.js | 1 - 7 files changed, 77 insertions(+), 70 deletions(-) diff --git a/node_modules/ace/lib/ace/edit_session.js b/node_modules/ace/lib/ace/edit_session.js index 7813b3d0..81ae0680 100644 --- a/node_modules/ace/lib/ace/edit_session.js +++ b/node_modules/ace/lib/ace/edit_session.js @@ -1158,7 +1158,7 @@ EditSession.$uid = 0; this.addFolds(delta.folds); } } - if (!dontSelect && this.$undoSelect) { + if (!dontSelect) { // console.log(deltas.selectionBefore + "uuu") if (deltas.selectionBefore) this.selection.fromJSON(deltas.selectionBefore); @@ -1187,7 +1187,7 @@ EditSession.$uid = 0; } } - if (!dontSelect && this.$undoSelect) { + if (!dontSelect) { if (deltas.selectionAfter) this.selection.fromJSON(deltas.selectionAfter); else diff --git a/node_modules/ace/lib/ace/layer/font_metrics.js b/node_modules/ace/lib/ace/layer/font_metrics.js index 3959cb29..7fea61e4 100644 --- a/node_modules/ace/lib/ace/layer/font_metrics.js +++ b/node_modules/ace/lib/ace/layer/font_metrics.js @@ -172,7 +172,7 @@ var FontMetrics = exports.FontMetrics = function(parentEl, interval) { this.getCharacterWidth = function(ch) { var w = this.charSizes[ch]; if (w === undefined) { - w = this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width; + this.charSizes[ch] = this.$measureCharWidth(ch) / this.$characterSize.width; } return w; }; diff --git a/node_modules/ace/lib/ace/placeholder.js b/node_modules/ace/lib/ace/placeholder.js index c4c88b11..0e299594 100644 --- a/node_modules/ace/lib/ace/placeholder.js +++ b/node_modules/ace/lib/ace/placeholder.js @@ -70,7 +70,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) this.$pos = pos; // Used for reset var undoStack = session.getUndoManager().$undoStack || session.getUndoManager().$undostack || {length: -1}; - this.$undoStackDepth = undoStack.length; + this.$undoStackDepth = undoStack.length; this.setup(); session.selection.on("changeCursor", this.$onCursorChange); @@ -90,21 +90,21 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) var _self = this; var doc = this.doc; var session = this.session; + var pos = this.$pos; this.selectionBefore = session.selection.toJSON(); if (session.selection.inMultiSelectMode) session.selection.toSingleRange(); - this.pos = doc.createAnchor(this.$pos.row, this.$pos.column); - var pos = this.pos; - pos.$insertRight = true; - pos.detach(); - pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false); + this.pos = doc.createAnchor(pos.row, pos.column); + this.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column + this.length), this.mainClass, null, false); + this.pos.on("change", function(event) { + session.removeMarker(_self.markerId); + _self.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.mainClass, null, false); + }); this.others = []; this.$others.forEach(function(other) { var anchor = doc.createAnchor(other.row, other.column); - anchor.$insertRight = true; - anchor.detach(); _self.others.push(anchor); }); session.setUndoSelect(false); @@ -117,12 +117,16 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) * **/ this.showOtherMarkers = function() { - if (this.othersActive) return; + if(this.othersActive) return; var session = this.session; var _self = this; this.othersActive = true; this.others.forEach(function(anchor) { anchor.markerId = session.addMarker(new Range(anchor.row, anchor.column, anchor.row, anchor.column+_self.length), _self.othersClass, null, false); + anchor.on("change", function(event) { + session.removeMarker(anchor.markerId); + anchor.markerId = session.addMarker(new Range(event.value.row, event.value.column, event.value.row, event.value.column+_self.length), _self.othersClass, null, false); + }); }); }; @@ -133,7 +137,7 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) * **/ this.hideOtherMarkers = function() { - if (!this.othersActive) return; + if(!this.othersActive) return; this.othersActive = false; for (var i = 0; i < this.others.length; i++) { this.session.removeMarker(this.others[i].markerId); @@ -147,61 +151,64 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) * **/ this.onUpdate = function(delta) { - if (this.$updating) - return this.updateAnchors(delta); - var range = delta; - if (range.start.row !== range.end.row) return; - if (range.start.row !== this.pos.row) return; + if(range.start.row !== range.end.row) return; + if(range.start.row !== this.pos.row) return; + if (this.$updating) return; this.$updating = true; var lengthDiff = delta.action === "insert" ? range.end.column - range.start.column : range.start.column - range.end.column; - var inMainRange = range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1; - var distanceFromStart = range.start.column - this.pos.column; - this.updateAnchors(delta); - - if (inMainRange) + if(range.start.column >= this.pos.column && range.start.column <= this.pos.column + this.length + 1) { + var distanceFromStart = range.start.column - this.pos.column; this.length += lengthDiff; - - if (inMainRange && !this.session.$fromUndo) { - if (delta.action === 'insert') { - for (var i = this.others.length - 1; i >= 0; i--) { - var otherPos = this.others[i]; - var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart}; - this.doc.insertMergedLines(newPos, delta.lines); + if(!this.session.$fromUndo) { + if(delta.action === 'insert') { + for (var i = this.others.length - 1; i >= 0; i--) { + var otherPos = this.others[i]; + var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart}; + if(otherPos.row === range.start.row && range.start.column < otherPos.column) + newPos.column += lengthDiff; + this.doc.insertMergedLines(newPos, delta.lines); + } + } else if(delta.action === 'remove') { + for (var i = this.others.length - 1; i >= 0; i--) { + var otherPos = this.others[i]; + var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart}; + if(otherPos.row === range.start.row && range.start.column < otherPos.column) + newPos.column += lengthDiff; + this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff)); + } } - } else if (delta.action === 'remove') { - for (var i = this.others.length - 1; i >= 0; i--) { - var otherPos = this.others[i]; - var newPos = {row: otherPos.row, column: otherPos.column + distanceFromStart}; - this.doc.remove(new Range(newPos.row, newPos.column, newPos.row, newPos.column - lengthDiff)); + // Special case: insert in beginning + if(range.start.column === this.pos.column && delta.action === 'insert') { + setTimeout(function() { + this.pos.setPosition(this.pos.row, this.pos.column - lengthDiff); + for (var i = 0; i < this.others.length; i++) { + var other = this.others[i]; + var newPos = {row: other.row, column: other.column - lengthDiff}; + if(other.row === range.start.row && range.start.column < other.column) + newPos.column += lengthDiff; + other.setPosition(newPos.row, newPos.column); + } + }.bind(this), 0); + } + else if(range.start.column === this.pos.column && delta.action === 'remove') { + setTimeout(function() { + for (var i = 0; i < this.others.length; i++) { + var other = this.others[i]; + if(other.row === range.start.row && range.start.column < other.column) { + other.setPosition(other.row, other.column - lengthDiff); + } + } + }.bind(this), 0); } } + this.pos._emit("change", {value: this.pos}); + for (var i = 0; i < this.others.length; i++) { + this.others[i]._emit("change", {value: this.others[i]}); + } } - this.$updating = false; - this.updateMarkers(); - }; - - this.updateAnchors = function(delta) { - this.pos.onChange(delta); - for (var i = this.others.length; i--;) - this.others[i].onChange(delta); - this.updateMarkers(); - }; - - this.updateMarkers = function() { - if (this.$updating) - return; - var _self = this; - var session = this.session; - var updateMarker = function(pos, className) { - session.removeMarker(pos.markerId); - pos.markerId = session.addMarker(new Range(pos.row, pos.column, pos.row, pos.column+_self.length), className, null, false); - }; - updateMarker(this.pos, this.mainClass); - for (var i = this.others.length; i--;) - updateMarker(this.others[i], this.othersClass); }; /** @@ -230,10 +237,14 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) * **/ this.detach = function() { - this.session.removeMarker(this.pos && this.pos.markerId); + this.session.removeMarker(this.markerId); this.hideOtherMarkers(); this.doc.removeEventListener("change", this.$onUpdate); this.session.selection.removeEventListener("changeCursor", this.$onCursorChange); + this.pos.detach(); + for (var i = 0; i < this.others.length; i++) { + this.others[i].detach(); + } this.session.setUndoSelect(true); this.session = null; }; @@ -245,8 +256,8 @@ var PlaceHolder = function(session, length, pos, others, mainClass, othersClass) * **/ this.cancel = function() { - if (this.$undoStackDepth === -1) - return; + if(this.$undoStackDepth === -1) + throw Error("Canceling placeholders only supported with undo manager attached to session."); var undoManager = this.session.getUndoManager(); var undosRequired = (undoManager.$undoStack || undoManager.$undostack).length - this.$undoStackDepth; for (var i = 0; i < undosRequired; i++) { diff --git a/node_modules/architect-build/module-deps.js b/node_modules/architect-build/module-deps.js index daae178c..083429bd 100644 --- a/node_modules/architect-build/module-deps.js +++ b/node_modules/architect-build/module-deps.js @@ -346,11 +346,8 @@ function removeUseStrict(module) { } function removeLicenceComments(module) { - if (/\.(js|jsx|css|less)/.test(module.path)) { - module.source = module.source.replace(/(\n|;|^|,)(?:[ \t]*(?:\/\*(?:[^*]|[*](?![/]))*?\*\/|\/\/.*\n))+(\n?)/gm, function(match, $1, $2) { - return $1 == $2 ? $1 : $1 + $2; - }); - } + if (/\.(js|jsx|css|less)/.test(module.path)) + module.source = module.source.replace(/(?:(;)|\n|^)\s*\/\*[\d\D]*?\*\/|(\n|^)\s*\/\/.*/g, "$1"); } function removeLicenceCommentsKeepLines(module) { if (/\.(js|jsx|css|less)/.test(module.path)) { diff --git a/package.json b/package.json index 307aafb4..70534d31 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "c9" ], "c9plugins": { - "c9.ide.language": "#2b5184c931", + "c9.ide.language": "#a6ffafabce", "c9.ide.language.css": "#a649f2a710", "c9.ide.language.generic": "#77d43cfaf0", "c9.ide.language.html": "#0f4078c187", @@ -106,7 +106,7 @@ "c9.ide.run.build": "#0598fff697", "c9.ide.run.debug.xdebug": "#61dcbd0180", "c9.ide.save": "#4a4a60a004", - "c9.ide.scm": "#37a4ed0acf", + "c9.ide.scm": "#aabd0d181e", "c9.ide.terminal.monitor": "#b76f1c9f24", "c9.ide.test": "#26cd260224", "c9.ide.test.mocha": "#f6cc482886", diff --git a/plugins/c9.ide.tree/style.css b/plugins/c9.ide.tree/style.css index 7d23332f..7137f666 100644 --- a/plugins/c9.ide.tree/style.css +++ b/plugins/c9.ide.tree/style.css @@ -20,7 +20,7 @@ color : @selected-color; } -.filetree .tree-row.projectRoot:first-child { +.filetree .tree-row.projectRoot, .filetree .tree-row:first-child { margin-right: @tree-first-row-margin-right; } diff --git a/plugins/c9.ide.tree/tree.js b/plugins/c9.ide.tree/tree.js index 477b0540..788068a8 100644 --- a/plugins/c9.ide.tree/tree.js +++ b/plugins/c9.ide.tree/tree.js @@ -277,7 +277,6 @@ define(function(require, exports, module) { btnTreeSettings.setAttribute("submenu", mnuFilesSettings); tree.renderer.on("scrollbarVisibilityChanged", updateScrollBarSize); tree.renderer.on("resize", updateScrollBarSize); - tree.renderer.scrollBarV.$minWidth = 10; function updateScrollBarSize() { var scrollBarV = tree.renderer.scrollBarV; var w = scrollBarV.isVisible ? scrollBarV.getWidth() : 0;