Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ before_script:
- npm install -g typescript -v 2.1.5
- npm install
- npm run compile
script: nvm use && npm run test-debugger
script: nvm use && npm run test && npm run test-debugger
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"vscode:prepublish": "tsc -p ./src",
"compile": "tsc -p ./src",
"watch": "tsc -w -p ./src",
"test": "node ./node_modules/mocha/bin/mocha --recursive ./out/*.test.js",
"test-debugger": "node ./node_modules/mocha/bin/mocha --timeout 15000 -u tdd ./out/debugger/tests/*.js",
"postinstall": "node ./node_modules/vscode/bin/install",
"update-all-grammars": "node scripts/update-all-grammars",
Expand Down
20 changes: 20 additions & 0 deletions src/languageConfiguration.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import assert = require('assert');
import languageConfiguration from './languageConfiguration'

describe('wordPattern', function () {
const wordPattern = languageConfiguration.wordPattern;

it('should not match leading colon in symbols (#257)', function() {
const text = ':fnord';
const matches = text.match(wordPattern);

assert.equal(matches[0], 'fnord');
});

it('should not match leading colons in constants (#257)', function() {
const text = '::Bar';
const matches = text.match(wordPattern);

assert.equal(matches[0], 'Bar');
});
});
9 changes: 9 additions & 0 deletions src/languageConfiguration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const languageConfiguration = {
indentationRules: {
increaseIndentPattern: /^(\s*(module|class|((private|protected)\s+)?def|unless|if|else|elsif|case|when|begin|rescue|ensure|for|while|until|(?=.*?\b(do|begin|case|if|unless)\b)("(\\.|[^\\"])*"|'(\\.|[^\\'])*'|[^#"'])*(\s(do|begin|case)|[-+=&|*/~%^<>~]\s*(if|unless)))\b(?![^;]*;.*?\bend\b)|("(\\.|[^\\"])*"|'(\\.|[^\\'])*'|[^#"'])*(\((?![^\)]*\))|\{(?![^\}]*\})|\[(?![^\]]*\]))).*$/,
decreaseIndentPattern: /^\s*([}\]]([,)]?\s*(#|$)|\.[a-zA-Z_]\w*\b)|(end|rescue|ensure|else|elsif|when)\b)/,
},
wordPattern: /(-?\d+(?:\.\d+))|([A-Za-z][^-`~@#%^&()=+[{}|;:'",<>/.*\]\s\\!?]*[!?]?)/,
};

export default languageConfiguration;
9 changes: 2 additions & 7 deletions src/ruby.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ExtensionContext, languages, workspace } from 'vscode';

import * as utils from './utils';

import languageConfiguration from './languageConfiguration';
import { registerCompletionProvider } from './providers/completion';
import { registerFormatter } from './providers/formatter';
import { registerHighlightProvider } from './providers/highlight';
Expand All @@ -20,13 +21,7 @@ export function activate(context: ExtensionContext) {
const subs = context.subscriptions;

// register language config
languages.setLanguageConfiguration('ruby', {
indentationRules: {
increaseIndentPattern: /^(\s*(module|class|((private|protected)\s+)?def|unless|if|else|elsif|case|when|begin|rescue|ensure|for|while|until|(?=.*?\b(do|begin|case|if|unless)\b)("(\\.|[^\\"])*"|'(\\.|[^\\'])*'|[^#"'])*(\s(do|begin|case)|[-+=&|*/~%^<>~]\s*(if|unless)))\b(?![^;]*;.*?\bend\b)|("(\\.|[^\\"])*"|'(\\.|[^\\'])*'|[^#"'])*(\((?![^\)]*\))|\{(?![^\}]*\})|\[(?![^\]]*\]))).*$/,
decreaseIndentPattern: /^\s*([}\]]([,)]?\s*(#|$)|\.[a-zA-Z_]\w*\b)|(end|rescue|ensure|else|elsif|when)\b)/,
},
wordPattern: /(-?\d+(?:\.\d+))|(:?[A-Za-z][^-`~@#%^&()=+[{}|;:'",<>/.*\]\s\\!?]*[!?]?)/,
});
languages.setLanguageConfiguration('ruby', languageConfiguration);

// Register providers
registerHighlightProvider(context, DOCUMENT_SELECTOR);
Expand Down