-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add commands to insert/run selected text (#23)
Add command x-terminal:insert-selected-text Add command x-terminal:run-selected-text Add `*` to active terminal title Add setting to allow hidden terminals to stay active
- Loading branch information
Showing
12 changed files
with
501 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** @babel */ | ||
|
||
import * as xTerminal from '../src/x-terminal' | ||
|
||
const xTerminalInstance = xTerminal.getInstance() | ||
|
||
describe('x-terminal', () => { | ||
describe('getSelectedText()', () => { | ||
it('returns selection', () => { | ||
spyOn(atom.workspace, 'getActiveTextEditor').and.returnValue({ | ||
getSelectedText () { | ||
return 'selection' | ||
}, | ||
}) | ||
const selection = xTerminalInstance.getSelectedText() | ||
expect(selection).toBe('selection') | ||
}) | ||
|
||
it('returns removes newlines at the end', () => { | ||
spyOn(atom.workspace, 'getActiveTextEditor').and.returnValue({ | ||
getSelectedText () { | ||
return 'line1\r\nline2\r\n' | ||
}, | ||
}) | ||
const selection = xTerminalInstance.getSelectedText() | ||
expect(selection).toBe('line1\r\nline2') | ||
}) | ||
|
||
it('returns entire line if nothing selected and moves down', () => { | ||
const moveDown = jasmine.createSpy('moveDown') | ||
spyOn(atom.workspace, 'getActiveTextEditor').and.returnValue({ | ||
getSelectedText () { | ||
return '' | ||
}, | ||
getCursorBufferPosition () { | ||
return { row: 1, column: 1 } | ||
}, | ||
lineTextForBufferRow (row) { | ||
return `line${row}` | ||
}, | ||
moveDown, | ||
}) | ||
const selection = xTerminalInstance.getSelectedText() | ||
expect(selection).toBe('line1') | ||
expect(moveDown).toHaveBeenCalledWith(1) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.