Skip to content

Commit

Permalink
feat: back to coding line, close #13.
Browse files Browse the repository at this point in the history
  • Loading branch information
lvjiaxuan committed Mar 22, 2023
1 parent 92f401c commit 43e8a85
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ExtensionContext, Position, Range, SnippetString, commands, languages, window } from 'vscode'
import { ExtensionContext, Position, Range, Selection, SnippetString, TextEditorRevealType, commands, languages, window } from 'vscode'
import { existFileSync, getTextBylines } from './utils'
import { getBlockComment, getExtension, getLineComment } from './languageDefaults'
import log from './log'
Expand Down Expand Up @@ -95,7 +95,6 @@ const disableForFile = commands.registerCommand('eslint-disable.entire', async (
const startLineText = getTextBylines(0)
const startLineTextMatch = startLineText?.match(/\/\* eslint-disable (?<rules>.+) \*\//i)

const lineComment = getLineComment(activeTextEditor.document.languageId)
const blockComment = getBlockComment(activeTextEditor.document.languageId)

if (startLineTextMatch) {
Expand Down Expand Up @@ -137,6 +136,16 @@ const disableForFile = commands.registerCommand('eslint-disable.entire', async (
new Position(0, 0),
)
}

activeTextEditor.revealRange(
new Range(new Position(selection.start.line, 0), new Position(selection.start.line, 0)),
TextEditorRevealType.InCenterIfOutsideViewport,
)

activeTextEditor.selection = new Selection(
new Position(selection.start.line + 1, selection.start.character),
new Position(selection.start.line + 1, selection.start.character),
)
})

const disableAllForFile = commands.registerCommand('eslint-disable.all', () => {
Expand Down

0 comments on commit 43e8a85

Please sign in to comment.