Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use buffer.getRange + fix the tests #81

Merged
merged 6 commits into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"no-duplicate-imports": 0,
"flowtype/no-types-missing-file-annotation": 1,
"react/no-string-refs": 1,
"prefer-destructuring": 1
"prefer-destructuring": 1,
"react/destructuring-assignment": "off"
},
"globals": {
"atom": "readonly"
Expand Down
1 change: 0 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,3 @@ decls

[options]
module.system=node
suppress_comment= \\(.\\|\n\\)*\\$FlowIgnore
30 changes: 26 additions & 4 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,36 @@ jobs:
channel: ${{ matrix.atom_channel }}

- name: Install dependencies
run: |
apm install
run: apm install

- name: Run tests 👩🏾‍💻
run: npm run test

Lint:
if: "!contains(github.event.head_commit.message, '[skip ci]')"
runs-on: ubuntu-latest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Commit lint ✨
uses: wagoid/commitlint-github-action@v2

- name: Setup Pnpm
uses: pnpm/action-setup@v2
with:
version: 6

- name: Install dependencies
run: pnpm install --frozen-lockfile

# - name: Format ✨
# run: pnpm run test.format

- name: Flow
run: npm run test.flow
run: pnpm run test.flow

- name: Lint
run: npm run test.lint
run: pnpm run test.lint
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
Intentions
=========

[![CI](https://github.com/steelbrain/intentions/actions/workflows/CI.yml/badge.svg)](https://github.com/steelbrain/intentions/actions/workflows/CI.yml)

Intentions is a base package that provides an easy-to-use API to show intentions based in Atom.

#### Usage
Expand Down
7 changes: 2 additions & 5 deletions lib/providers-highlight.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
/* @flow */

import { Range } from "atom"
import type { TextEditor } from "atom"
import { provider as validateProvider, suggestionsShow as validateSuggestions } from "./validate"
import { create as createElement, PADDING_CHARACTER } from "./elements/highlight"
Expand Down Expand Up @@ -39,10 +38,8 @@ export default class ProvidersHighlight {
const scopes = textEditor.scopeDescriptorForBufferPosition(bufferPosition).getScopesArray()
scopes.push("*")

const visibleRange = Range.fromObject([
textEditor.bufferPositionForScreenPosition([textEditor.getFirstVisibleScreenRow(), 0]),
textEditor.bufferPositionForScreenPosition([textEditor.getLastVisibleScreenRow(), 0])
])
const visibleRange = { ...textEditor.getBuffer().getRange() }

// Setting this to infinity on purpose, cause the buffer position just marks visible column
// according to element width
visibleRange.end.column = Infinity
Expand Down
2 changes: 1 addition & 1 deletion lib/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Point, Range, TextEditor, TextEditorMarker } from "atom"

export type ListItem = {
// Automatically added
__$sb_intentions_class: string,
__$sb_intentions_class?: string,

// From providers
icon?: string,
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"vanilla-jsx": "^3.0.2"
},
"devDependencies": {
"eslint-config-steelbrain": "^7",
"flow-bin": "^0.130.0",
"eslint-config-steelbrain": "7",
"flow-bin": "0.130.0",
"jasmine-fix": "^1.3.1",
"@types/atom": "latest"
},
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion spec/helpers-spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
/* @flow */

import * as Helpers from "../lib/helpers"
import type { ListItem } from "../lib/types"

describe("Helpers", function() {
describe("processListItems", function() {
it("works", function() {
let suggestions: Array<Record<string, any>> = [
let suggestions: Array<ListItem> = [
{
priority: 100,
title: "title 1",
Expand Down