tab causes entire line to shift

When I use tab it causes the entire line to shift regardless of where the cursor is.

Is there a way to only have it tab to the right from where the cursor is?

I meet the same problem, Have you solved this problem?

The following is my code, which is consistent with the behavior of vscode, combined with the source code of the insertTab and indentMore methods provided by codemirror。
hope this helps

  {
    key: 'Tab',
    run: (view: EditorView) => {
      // $ tab不需要整行缩进, 光标聚焦点为起始位置开始缩进
      // https://discuss.codemirror.net/t/is-it-possible-deletetab-command/4453/2
      /**
       * tips: 与vscode保持一致. 如下方法是commands.insertTab与commands.indentMore的部分源码实现的整合
       * 1. 选择区域start\end同一行, 使用\t替换
       * 2. 选择区域start\end不在同一行, 多行缩进(每一行行首都加\t)
       * 3. 选择区域start\end在同一个位置,加一个\t
       */
      const { state } = view;
      const update = state.changeByRange((range) => {
        const { from, to } = range;
        const startLine = state.doc.lineAt(from).number;
        const endLine = state.doc.lineAt(to).number;
        if (startLine === endLine) {
          // 单光标 或者 选择区域为一行
          const text = state.facet(indentUnit);
          return {
            changes: { from, to, insert: text },
            range: EditorSelection.cursor(range.from + text.length),
          };
        } else {
          // 选择区域为多行
          let atLine = -1;
          const changes: Array<ChangeSpec> = [];
          for (let pos = range.from; pos <= range.to; ) {
            const line = state.doc.lineAt(pos);
            if (line.number > atLine && (range.empty || range.to > line.from)) {
              changes.push({
                from: line.from,
                insert: state.facet(indentUnit),
              });
              atLine = line.number;
            }
            pos = line.to + 1;
          }
          const changeSet = state.changes(changes);
          return {
            changes: changes,
            range: EditorSelection.range(
              changeSet.mapPos(range.anchor, 1),
              changeSet.mapPos(range.head, 1),
            ),
          };
        }
      });
      view.dispatch(state.update(update, { userEvent: 'input.indent' }));
      return true;
    },
    preventDefault: true,
  },