Skip to content

Commit

Permalink
Force highlighting to only run with the latest version, instead of al…
Browse files Browse the repository at this point in the history
…l the time
  • Loading branch information
david-driscoll committed Sep 14, 2015
1 parent 2a11b89 commit e609e21
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 18 deletions.
2 changes: 1 addition & 1 deletion disable-other-packages.js
Expand Up @@ -13,7 +13,7 @@ season.writeFileSync(path.join(ATOM_HOME, 'config.cson.bak'), config);

var disabledPackages = config['*'].core.disabledPackages;

var requiredPackages = Object.keys(require('./package.json')['package-dependencies']);
var requiredPackages = require('./package.json')['package-deps'];
fs.readdirSync(path.join(ATOM_HOME, 'packages')).forEach(function(package) {
if (requiredPackages.indexOf(package) === -1 && disabledPackages.indexOf(package) === -1 && package !== "atom-typescript" && package !== "omnisharp-atom") {
disabledPackages.push(package);
Expand Down
31 changes: 14 additions & 17 deletions lib/omnisharp-atom/features/highlight.ts
Expand Up @@ -6,7 +6,7 @@ import {Observable, Subject, ReplaySubject, Scheduler, CompositeDisposable, Disp
var AtomGrammar = require((<any>atom).config.resourcePath + "/node_modules/first-mate/lib/grammar.js");
var Range: typeof TextBuffer.Range = <any>require('atom').Range;

const DEBOUNCE_TIME = 480/*240*/;
const DEBOUNCE_TIME = 240/*240*/;

class Highlight implements OmniSharp.IFeature {
private disposable: Rx.CompositeDisposable;
Expand Down Expand Up @@ -36,21 +36,12 @@ class Highlight implements OmniSharp.IFeature {
isObserveRetokenizing(
Omni.listener.observeHighlight
.map(z => ({ editor: find(this.editors, editor => editor.getPath() === z.request.FileName), request: z.request, response: z.response }))
.flatMap(z => Omni.activeEditor.take(1).where(x => x !== z.editor).map(x => z))
)
.subscribe(({editor, request, response}) => {
editor.getGrammar && (<any>editor.getGrammar()).setResponses(response.Highlights, request.ProjectNames.length > 0);
}));

this.disposable.add(isObserveRetokenizing(
Omni.listener.observeHighlight
.map(z => ({ editor: find(atom.workspace.getTextEditors(), editor => editor.getPath() == z.request.FileName), request: z.request, response: z.response }))
.flatMap(z => Omni.activeEditor.take(1).where(x => x === z.editor).map(x => z))
)
.debounce(DEBOUNCE_TIME)
.subscribe(({request, response, editor}) => {
editor.displayBuffer.tokenizedBuffer['silentRetokenizeLines']();
}));

this.disposable.add(isEditorObserveRetokenizing(
Observable.merge(Omni.activeEditor,
Omni.activeFramework
Expand Down Expand Up @@ -131,7 +122,7 @@ class Highlight implements OmniSharp.IFeature {
return editor.displayBuffer.tokenizedBuffer['_retokenizeLines'].apply(this, arguments);
};

/*(<any>editor.displayBuffer.tokenizedBuffer).tokenizeInBackground = function() {
(<any>editor.displayBuffer.tokenizedBuffer).tokenizeInBackground = function() {
if (!this.visible || this.pendingChunk || !this.isAlive())
return;

Expand All @@ -142,7 +133,7 @@ class Highlight implements OmniSharp.IFeature {
this.tokenizeNextChunk();
}
});
};*/
};

disposable.add(Disposable.create(() => {
grammar.linesToFetch = [];
Expand All @@ -160,7 +151,7 @@ class Highlight implements OmniSharp.IFeature {
disposable.add(issueRequest
.debounce(DEBOUNCE_TIME)
.flatMap(z => Omni.getProject(editor).map(z => z.activeFramework.Name === 'all' ? '' : (z.name + '+' + z.activeFramework.ShortName)).timeout(200, Observable.just('')))
.subscribe((framework) => {
.flatMapLatest((framework) => {
var projects = [];
if (framework)
projects = [framework];
Expand All @@ -169,7 +160,7 @@ class Highlight implements OmniSharp.IFeature {
if (!linesToFetch || !linesToFetch.length)
linesToFetch = [];

Omni.request(editor, client => client.highlight({
return Omni.request(editor, client => client.highlight({
ProjectNames: projects,
Lines: <any>linesToFetch,
ExcludeClassifications: [
Expand All @@ -179,8 +170,14 @@ class Highlight implements OmniSharp.IFeature {
OmniSharp.Models.HighlightClassification.Operator,
OmniSharp.Models.HighlightClassification.Keyword
]
}));
}));
})).map(z => ({ projects, response: z }));
})
.subscribe(ctx => {
var {response, projects} = ctx;
editor.getGrammar && (<any>editor.getGrammar()).setResponses(response.Highlights, projects.length > 0);
editor.displayBuffer.tokenizedBuffer['silentRetokenizeLines']();
})
);

disposable.add(Omni.getProject(editor)
.flatMap(z => z.observe.activeFramework).subscribe(() => {
Expand Down

0 comments on commit e609e21

Please sign in to comment.