Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
ab71656
Added line comment toggling only at start of code added #11953
heysupratim Nov 25, 2015
7529042
added line toggling like sublime where subsequent comment position is…
heysupratim Nov 25, 2015
e2fe451
uneven seelcted led to wrong toggle of comments , recalucated curssor…
heysupratim Nov 25, 2015
1d7e7b1
lint error of equality - lint is awesome
heysupratim Nov 25, 2015
66a11c7
removed duplicate variable declaration
heysupratim Nov 25, 2015
95c8a6f
re wrote line comment test cases
heysupratim Nov 25, 2015
a230b71
removed lint errors in EditorCommandHandler-test.js
heysupratim Nov 25, 2015
e22a55d
Merge remote-tracking branch 'upstream/master' into lineCommentBugFix
heysupratim Dec 9, 2015
989754e
added preference for Editor linecommentIndent
heysupratim Jan 11, 2016
cd0ca6f
added preference handling -preference indentLineComment with default …
heysupratim Jan 11, 2016
a0ba41d
made test cases for both prefernce set values fix #11953
heysupratim Jan 11, 2016
4c1c82f
removed merge conflicts and added comments
heysupratim Jan 11, 2016
57d7ad2
Merge branch 'master' into lineCommentBugFix
heysupratim Jan 28, 2016
62f08e5
Removed styling issues and removed unwanted comments
heysupratim Jan 28, 2016
4292b2e
Merge branch 'master' into lineCommentBugFix
heysupratim Jan 28, 2016
79e2942
seperated the test cases for both preference set and unset and reset …
heysupratim Jan 28, 2016
1ba50d1
Merge branch 'master' into lineCommentBugFix
heysupratim Feb 5, 2016
c8b3b5f
split the remaining two tests , hopefully this ends the brackets line…
heysupratim Feb 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,9 @@ define(function (require, exports, module) {
TAB_SIZE = "tabSize",
UPPERCASE_COLORS = "uppercaseColors",
USE_TAB_CHAR = "useTabChar",
WORD_WRAP = "wordWrap";
WORD_WRAP = "wordWrap",
INDENT_LINE_COMMENT = "indentLineComment";


var cmOptions = {};

Expand Down Expand Up @@ -207,7 +209,12 @@ define(function (require, exports, module) {
PreferencesManager.definePreference(WORD_WRAP, "boolean", true, {
description: Strings.DESCRIPTION_WORD_WRAP
});


PreferencesManager.definePreference(INDENT_LINE_COMMENT, "boolean", false, {
description: Strings.DESCRIPTION_INDENT_LINE_COMMENT
});


var editorOptions = Object.keys(cmOptions);

/** Editor preferences */
Expand Down Expand Up @@ -2514,6 +2521,27 @@ define(function (require, exports, module) {
return PreferencesManager.get(WORD_WRAP, _buildPreferencesContext(fullPath));
};

/**
* Sets lineCommentIndent option.
*
* @param {boolean} value
* @param {string=} fullPath Path to file to get preference for
* @return {boolean} true if value was valid
*/
Editor.setIndentLineComment = function (value, fullPath) {
var options = fullPath && {context: fullPath};
return PreferencesManager.set(INDENT_LINE_COMMENT, value, options);
};

/**
* Returns true if word wrap is enabled for the specified or current file
* @param {string=} fullPath Path to file to get preference for
* @return {boolean}
*/
Editor.getIndentLineComment = function (fullPath) {
return PreferencesManager.get(INDENT_LINE_COMMENT, _buildPreferencesContext(fullPath));
};

/**
* Runs callback for every Editor instance that currently exists
* @param {!function(!Editor)} callback
Expand Down
25 changes: 24 additions & 1 deletion src/editor/EditorCommandHandlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ define(function (require, exports, module) {
// Load dependent modules
var Commands = require("command/Commands"),
Strings = require("strings"),
Editor = require("editor/Editor").Editor,
CommandManager = require("command/CommandManager"),
EditorManager = require("editor/EditorManager"),
StringUtils = require("utils/StringUtils"),
Expand Down Expand Up @@ -206,8 +207,30 @@ define(function (require, exports, module) {

if (containsNotLineComment) {
// Comment out - prepend the first prefix to each line
line = doc.getLine(startLine);
var originalCursorPosition = line.search(/\S|$/);

var firstCharPosition,cursorPosition = originalCursorPosition;

for (i = startLine; i <= endLine; i++) {
editGroup.push({text: prefixes[0], start: {line: i, ch: 0}});
//check if preference for indent line comment is available otherwise go back to default indentation
if (Editor.getIndentLineComment()) {
//ignore the first line and recalculate cursor position for first non white space char of every line
if (i !== startLine) {
line = doc.getLine(i);
firstCharPosition = line.search(/\S|$/);
}
//if the non space first character position is before original start position , put comment at the new position otherwise older pos
if (firstCharPosition < originalCursorPosition) {
cursorPosition = firstCharPosition;
} else {
cursorPosition = originalCursorPosition;
}

editGroup.push({text: prefixes[0], start: {line: i, ch: cursorPosition}});
} else {
editGroup.push({text: prefixes[0], start: {line: i, ch: 0}});
}
}

// Make sure tracked selections include the prefix that was added at start of range
Expand Down
3 changes: 2 additions & 1 deletion src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -778,5 +778,6 @@ define({
"DESCRIPTION_SHOW_PANE_HEADER_BUTTONS" : "Toggle when to show the close and flip-view buttons on the header.",
"DEFAULT_PREFERENCES_JSON_HEADER_COMMENT" : "/*\n * This is a read-only file with the preferences supported\n * by {APP_NAME}.\n * Use this file as a reference to modify your preferences\n * file \"brackets.json\" opened in the other pane.\n * For more information on how to use preferences inside\n * {APP_NAME}, refer to the web page at https://github.com/adobe/brackets/wiki/How-to-Use-Brackets#preferences\n */",
"DEFAULT_PREFERENCES_JSON_DEFAULT" : "Default",
"DESCRIPTION_PURE_CODING_SURFACE" : "true to enable code only mode and hide all other UI elements in {APP_NAME}"
"DESCRIPTION_PURE_CODING_SURFACE" : "true to enable code only mode and hide all other UI elements in {APP_NAME}",
"DESCRIPTION_INDENT_LINE_COMMENT" : "true to enable indenting of line comments"
});
Loading