mirror of
https://github.com/atom/atom.git
synced 2026-01-26 07:19:06 -05:00
Add a kind property to Gutters
This commit is contained in:
@@ -6716,6 +6716,20 @@ describe('TextEditor', () => {
|
||||
const gutter = editor.addGutter(options)
|
||||
expect(editor.getGutters().length).toBe(2)
|
||||
expect(editor.getGutters()[1]).toBe(gutter)
|
||||
expect(gutter.kind).toBe('decorated')
|
||||
})
|
||||
|
||||
it('can add a custom line-number gutter', () => {
|
||||
expect(editor.getGutters().length).toBe(1)
|
||||
const options = {
|
||||
name: 'another-gutter',
|
||||
priority: 2,
|
||||
kind: 'line-number'
|
||||
}
|
||||
const gutter = editor.addGutter(options)
|
||||
expect(editor.getGutters().length).toBe(2)
|
||||
expect(editor.getGutters()[1]).toBe(gutter)
|
||||
expect(gutter.kind).toBe('line-number')
|
||||
})
|
||||
|
||||
it("does not allow a custom gutter with the 'line-number' name.", () => expect(editor.addGutter.bind(editor, {name: 'line-number'})).toThrow())
|
||||
|
||||
@@ -97,7 +97,7 @@ module.exports = class GutterContainer {
|
||||
|
||||
// The public interface is Gutter::decorateMarker or TextEditor::decorateMarker.
|
||||
addGutterDecoration (gutter, marker, options) {
|
||||
if (gutter.name === 'line-number') {
|
||||
if (gutter.kind === 'line-number') {
|
||||
options.type = 'line-number'
|
||||
} else {
|
||||
options.type = 'gutter'
|
||||
|
||||
@@ -11,6 +11,8 @@ module.exports = class Gutter {
|
||||
this.name = options && options.name
|
||||
this.priority = (options && options.priority != null) ? options.priority : DefaultPriority
|
||||
this.visible = (options && options.visible != null) ? options.visible : true
|
||||
this.kind = (options && options.kind != null) ? options.kind : 'decorated'
|
||||
this.labelFn = options && options.labelFn
|
||||
|
||||
this.emitter = new Emitter()
|
||||
}
|
||||
|
||||
@@ -258,6 +258,7 @@ class TextEditor {
|
||||
this.gutterContainer = new GutterContainer(this)
|
||||
this.lineNumberGutter = this.gutterContainer.addGutter({
|
||||
name: 'line-number',
|
||||
kind: 'line-number',
|
||||
priority: 0,
|
||||
visible: params.lineNumberGutterVisible
|
||||
})
|
||||
@@ -4211,6 +4212,16 @@ class TextEditor {
|
||||
// window. (default: -100)
|
||||
// * `visible` (optional) {Boolean} specifying whether the gutter is visible
|
||||
// initially after being created. (default: true)
|
||||
// * `type` (optional) {String} specifying the type of gutter to create. `'decorated'`
|
||||
// gutters are useful as a destination for decorations created with {Gutter::decorateMarker}.
|
||||
// `'line-number'` gutters
|
||||
// * `labelFn` (optional) {Function} called by a `'line-number'` gutter to generate the label for each line number
|
||||
// element. Should return a {String} that will be used to label the corresponding line.
|
||||
// * `lineData` an {Object} containing information about each line to label.
|
||||
// * `bufferRow` {Number} indicating the zero-indexed buffer index of this line.
|
||||
// * `screenRow` {Number} indicating the zero-indexed screen index.
|
||||
// * `foldable` {Boolean} that is `true` if a fold may be created here.
|
||||
// * `softWrapped` {Boolean} if this screen row is the soft-wrapped continuation of the same buffer row.
|
||||
//
|
||||
// Returns the newly-created {Gutter}.
|
||||
addGutter (options) {
|
||||
|
||||
Reference in New Issue
Block a user