Skip to content

Commit

Permalink
Merge branch 'master' into v1.110.0-release
Browse files Browse the repository at this point in the history
  • Loading branch information
confused-Techie committed Oct 16, 2023
2 parents 24f3df7 + 8625b77 commit 53d3ce2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
6 changes: 4 additions & 2 deletions packages/wrap-guide/lib/wrap-guide-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ module.exports = class WrapGuideElement {
const columns = uniqueAscending(args.newValue);
if (columns != null ? columns.length : undefined) {
atom.config.set('wrap-guide.columns', columns);
atom.config.set('editor.preferredLineLength', columns[columns.length - 1],
{scopeSelector: `.${this.editor.getGrammar().scopeName}`});
if (atom.config.get('wrap-guide.modifyPreferredLineLength')) {
atom.config.set('editor.preferredLineLength', columns[columns.length - 1],
{scopeSelector: `.${this.editor.getGrammar().scopeName}`});
}
return this.updateGuide();
}
};
Expand Down
5 changes: 5 additions & 0 deletions packages/wrap-guide/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@
},
"description": "Display guides at each of the listed character widths. Leave blank for one guide at your `editor.preferredLineLength`."
},
"modifyPreferredLineLength": {
"default": true,
"type": "boolean",
"description": "Modify the Editor's Preferred Line Length when changing Wrap Guide's Columns setting."
},
"enabled": {
"default": true,
"type": "boolean"
Expand Down
15 changes: 14 additions & 1 deletion packages/wrap-guide/spec/wrap-guide-element-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe("WrapGuideElement", function() {
for (let i = 0; i < columnCount; i++) {
columns.push(i * 10);
}

atom.config.set("wrap-guide.columns", columns);
waitsForPromise(() => editorElement.getComponent().getNextUpdatePromise());

Expand Down Expand Up @@ -245,6 +245,19 @@ describe("WrapGuideElement", function() {
expect(wrapGuide).toBeVisible();
});
});

it("leaves alone preferredLineLength if modifyPreferredLineLength is false", () => {
const initial = atom.config.get("editor.preferredLineLength", { scope: editor.getRootScopeDescriptor() });
atom.config.set("wrap-guide.modifyPreferredLineLength", false);

atom.config.set("wrap-guide.columns", [ initial, initial + 10]);
waitsForPromise(() => editorElement.getComponent().getNextUpdatePromise());

runs(() => {
const length = atom.config.get("editor.preferredLineLength", { scope: editor.getRootScopeDescriptor() });
expect(length).toBe(initial);
});
});
});

describe("when the editor's scroll left changes", () => it("updates the wrap guide position to a relative position on screen", function() {
Expand Down

0 comments on commit 53d3ce2

Please sign in to comment.