Skip to content

Commit baeb926

Browse files
author
tomsdev
committed
Fix issue with Brackets Sprint 21
1 parent 21d147d commit baeb926

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

Diff for: README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ Reload **Brackets** and try it!
2525
You can open a **TypeScript project** or the **sample project** given
2626
with this extension in the Sample folder.
2727

28-
##Notes
28+
##Compatibility
2929

30-
* Syntax highlighting on TypeScript files only works with Brackets version sprint 20 (and later).
30+
* Tested on Mac and PC with Brackets version sprint 21.
3131

3232
##Roadmap
3333

Diff for: TypeScript/TypeScriptService.js

+1-7
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,12 @@ define(function (require, exports, module) {
115115
}
116116

117117
var fullPath = current.document.file.fullPath;
118-
// Change the current mode to typescript if the file has the extension .ts
119-
// We have to do this because typescript mode is not defined in Brackets
120-
// for the moment (in EditorUtils.js)
121-
if (PathUtils.hasExtensions(fullPath, ["ts"])) {
122-
current.setModeForDocument("text/typescript");
123-
}
124118

125119
// Here we could detach the session from the previous editor
126120
//if (_currentSession && previous) { }
127121

128122
_currentSession = null;
129-
if (current.getModeForSelection() === TypeScriptUtils.MODE_NAME) {
123+
if (current.getLanguageForSelection().getId() === TypeScriptUtils.LANGUAGE_ID) {
130124
console.log("Current session changing to: ", fullPath);
131125

132126
getSession(current.document).done(function (session) {

Diff for: TypeScript/TypeScriptUtils.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ define(function (require, exports, module) {
2929
"use strict";
3030

3131
var MODE_NAME = "text/typescript";
32-
32+
var LANGUAGE_ID = "typescript";
33+
3334
/**
3435
* Get a typescript-specific event name
3536
*/
@@ -83,6 +84,7 @@ define(function (require, exports, module) {
8384

8485
// Define public API
8586
exports.MODE_NAME = MODE_NAME;
87+
exports.LANGUAGE_ID = LANGUAGE_ID;
8688
exports.eventName = eventName;
8789
exports.getObjectsDiff = getObjectsDiff;
8890
exports.getObjectKeys = getObjectKeys;

Diff for: TypeScriptQuickEdit/main.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ define(function (require, exports, module) {
8484
function typeScriptFunctionProvider(hostEditor, pos) {
8585
var result = new $.Deferred();
8686
// Only provide a TypeScript editor when cursor is in TypeScript content
87-
if (hostEditor.getModeForSelection() !== TypeScriptUtils.MODE_NAME) {
87+
var languageId = hostEditor.getLanguageForSelection().getId();
88+
if (languageId !== TypeScriptUtils.LANGUAGE_ID) {
8889
return null;
8990
}
9091
// Only provide TypeScript editor if the selection is within a single line

Diff for: main.js

+10
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@
2828
define(function (require, exports, module) {
2929
"use strict";
3030

31+
var LanguageManager = brackets.getModule("language/LanguageManager");
32+
33+
LanguageManager.defineLanguage("typescript", {
34+
name: "TypeScript",
35+
mode: ["javascript", "text/typescript"],
36+
fileExtensions: ["ts"],
37+
blockComment: ["/*", "*/"],
38+
lineComment: "//"
39+
});
40+
3141
exports.TypeScript = require("TypeScript/main");
3242
exports.TypeScriptQuickEdit = require("TypeScriptQuickEdit/main");
3343
exports.TypeScriptCodeHints = require("TypeScriptCodeHints/main");

0 commit comments

Comments
 (0)