mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-08-06 08:57:38 +00:00
format
This commit is contained in:
@@ -4,9 +4,8 @@ import { undo, redo, indentMore, deleteLine } from '@codemirror/commands';
|
|||||||
import { EditorSelection } from '@codemirror/state';
|
import { EditorSelection } from '@codemirror/state';
|
||||||
import { Prec } from '@codemirror/state';
|
import { Prec } from '@codemirror/state';
|
||||||
|
|
||||||
const insertTab = (view) => {
|
const insertTab = (view)=>{
|
||||||
const shouldIndent = view.state.selection.ranges.some(range =>
|
const shouldIndent = view.state.selection.ranges.some((range)=>view.state.doc.lineAt(range.from).number !==
|
||||||
view.state.doc.lineAt(range.from).number !==
|
|
||||||
view.state.doc.lineAt(range.to).number
|
view.state.doc.lineAt(range.to).number
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -15,7 +14,7 @@ const insertTab = (view) => {
|
|||||||
const changes = [];
|
const changes = [];
|
||||||
const ranges = [];
|
const ranges = [];
|
||||||
|
|
||||||
for(const range of view.state.selection.ranges) {
|
for (const range of view.state.selection.ranges) {
|
||||||
console.log(range);
|
console.log(range);
|
||||||
changes.push({
|
changes.push({
|
||||||
from : range.from,
|
from : range.from,
|
||||||
@@ -31,9 +30,8 @@ const insertTab = (view) => {
|
|||||||
|
|
||||||
view.dispatch({
|
view.dispatch({
|
||||||
changes,
|
changes,
|
||||||
selection: EditorSelection.create(
|
selection : EditorSelection.create(
|
||||||
view.state.selection.ranges.map(range =>
|
view.state.selection.ranges.map((range)=>EditorSelection.cursor(
|
||||||
EditorSelection.cursor(
|
|
||||||
tr.changes.mapPos(range.from, 1) + 2
|
tr.changes.mapPos(range.from, 1) + 2
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user