Skip to content

Commit

Permalink
Merge pull request #443 from pulsar-edit/wrap-guide-decaf-ct
Browse files Browse the repository at this point in the history
Decaf `wrap-guide`
  • Loading branch information
confused-Techie authored Apr 9, 2023
2 parents b2c5049 + c911507 commit 222a31d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 191 deletions.
26 changes: 0 additions & 26 deletions packages/wrap-guide/lib/main.coffee

This file was deleted.

11 changes: 3 additions & 8 deletions packages/wrap-guide/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
* decaffeinate suggestions:
* DS102: Remove unnecessary code created because of implicit returns
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
const {CompositeDisposable} = require('atom');
const WrapGuideElement = require('./wrap-guide-element');

Expand All @@ -11,16 +6,16 @@ module.exports = {
this.subscriptions = new CompositeDisposable();
this.wrapGuides = new Map();

return this.subscriptions.add(atom.workspace.observeTextEditors(editor => {
this.subscriptions.add(atom.workspace.observeTextEditors(editor => {
if (this.wrapGuides.has(editor)) { return; }

const editorElement = atom.views.getView(editor);
const wrapGuideElement = new WrapGuideElement(editor, editorElement);

this.wrapGuides.set(editor, wrapGuideElement);
return this.subscriptions.add(editor.onDidDestroy(() => {
this.subscriptions.add(editor.onDidDestroy(() => {
this.wrapGuides.get(editor).destroy();
return this.wrapGuides.delete(editor);
this.wrapGuides.delete(editor);
})
);
})
Expand Down
137 changes: 0 additions & 137 deletions packages/wrap-guide/lib/wrap-guide-element.coffee

This file was deleted.

31 changes: 11 additions & 20 deletions packages/wrap-guide/lib/wrap-guide-element.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,6 @@
/*
* decaffeinate suggestions:
* DS101: Remove unnecessary use of Array.from
* DS102: Remove unnecessary code created because of implicit returns
* DS104: Avoid inline assignments
* DS205: Consider reworking code to avoid use of IIFEs
* DS207: Consider shorter variations of null checks
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md
*/
let WrapGuideElement;
const {CompositeDisposable} = require('atom');

module.exports =
(WrapGuideElement = class WrapGuideElement {
module.exports = class WrapGuideElement {
constructor(editor, editorElement) {
this.editor = editor;
this.editorElement = editorElement;
Expand Down Expand Up @@ -41,7 +30,7 @@ module.exports =
this.subscriptions.add(atom.config.onDidChange('editor.fontSize', () => {
// Wait for editor to finish updating before updating wrap guide
// TODO: Use async/await once this file is converted to JS
return this.editorElement.getComponent().getNextUpdatePromise().then(() => updateGuideCallback());
this.editorElement.getComponent().getNextUpdatePromise().then(() => updateGuideCallback());
})
);

Expand All @@ -50,19 +39,19 @@ module.exports =
this.subscriptions.add(this.editor.onDidChangeGrammar(() => {
this.configSubscriptions.dispose();
this.handleConfigEvents();
return updateGuideCallback();
updateGuideCallback();
})
);

this.subscriptions.add(this.editor.onDidDestroy(() => {
this.subscriptions.dispose();
return this.configSubscriptions.dispose();
this.configSubscriptions.dispose();
})
);

return this.subscriptions.add(this.editorElement.onDidAttach(() => {
this.subscriptions.add(this.editorElement.onDidAttach(() => {
this.attachToLines();
return updateGuideCallback();
updateGuideCallback();
})
);
}
Expand Down Expand Up @@ -176,8 +165,10 @@ module.exports =
const columns = this.getGuidesColumns(this.editor.getPath(), this.editor.getGrammar().scopeName);
return (() => {
const result = [];
for (let column of Array.from(columns)) {
if (!(column < 0)) { result.push(this.appendGuide(column)); } else {
for (let column of columns) {
if (!(column < 0)) {
result.push(this.appendGuide(column));
} else {
result.push(undefined);
}
}
Expand All @@ -193,4 +184,4 @@ module.exports =
guide.style.left = `${Math.round(columnWidth)}px`;
return this.element.appendChild(guide);
}
});
};

0 comments on commit 222a31d

Please sign in to comment.